Wednesday, July 18, 2012

variables inside awk print and sed

Simple & useful: [Many times i forfot this trick]


[mandy ~]$ echo $v1
75

[mandy ~]$ awk -F "|" ' { print $'"$v1"' } ' file_name
mandar
mpande
mp

[mandy ~]$ sed 's/'"$old_val"'/'"$new_val"'/g' file_name

No comments:

Post a Comment