2015年5月28日 星期四

[Linux 常見問題] How to use “:” as awk field separator?

Source From Here 
Question 
Given following command: 
$ echo -e "1:2:3:4\r\n5:6:7:8" | awk '{print $1}'
1:2:3:4
5:6:7:8

I expected to have output: 
1
5

How-To 
"-F" is a command line argument not awk syntax, try: 
$ echo -e "1:2:3:4\r\n5:6:7:8" | awk -F ':' '{print $1}'
1
5

Supplement 
Awk Introduction Tutorial – 7 Awk Print Examples

沒有留言:

張貼留言

[ Python 常見問題 ] python generator “send” function purpose?

Source From  Here   Question   Can someone give me an example of why the "send" function associated with Python generator function...