2012-12-27 17 views

回答

15

方法很多:

cut -d' ' -f1 <filename # If field separator is space 
cut -f1 <filename # If field separator is tab 
cut -d' ' -f1 <filename | cut -f1 # If field separator is space OR tab 
awk '{print $1}' filename 
while read x _ ; do echo $x ; done < filename 
1
cut -d " " -f1 test.txt 

其中的test.txt包含你输入线