抓取最后一个字段

由 徐永久 发表于 2004年12月15日 23:01。

field=`cut -d: -f8 file`

如果不知道最后一个字段第几个,可以用如下命令得到:

field=`awk -F: ‘{print $NF}’`

如果要得到最后一个字段前面的一个字段,可以用如下命令:

field=`awk -F: ‘{print $(NF-1)}’`

相关文章

您可以 发表评论, 或者从您的网站trackback

发表评论

*
To prove you're a person (not a spam script), type the security word shown in the picture.
Anti-spam image