Friday, October 22, 2010

cut and awk for same job : extract fields and join them

$ cat test.txt
a:b:c:d:e
a1:b1:c1:d1:e1

Welcome@computer_1012 ~
$ cat test.txt | cut -d: -f1,5 --output-delimiter="-"
a-e
a1-e1

Welcome@computer_1012 ~
$ cat test.txt | awk -F: '{print $1 "-" $5}'
a-e
a1-e1

No comments:

Blog Archive