2012-09-27 28 views

回答

0

试试这个perl的一行代码:如果您在第八百四十九破折号前找字

perl -ne 'print "$2\n" if m{^([^-]+\-){849}\s*(\w+)}' infile; 

做:

perl -ne 'print "$2\n" if m{^([^-]+\-){848}.+?\s*(\w+)\s*\-}' infile; 
+0

谢谢!第849次冲刺之前的单词怎么样? (对不起,我不知道Perl。) –

1

(假设数据都在同一行)

在这种情况下将切你的朋友

echo "Hello-World-I-Love-You" | cut -d- -f2 
> World 

-d-说明哪些字符划定了字段,-f2是字段号码。 man cut会告诉你更多。

cut -d- -f849 < infile 
0
awk -F"-" '{split($850,a," ");print a[1];}' file 
相关问题