Unix iTOps Tube

Monday, May 7, 2012

help with printf command


I'm trying to display Unix variable using printf command.



awk '{ if ( $0 ~ /string/ ) {

printf( "%s\n%s\n",$0,"dsd"); #this one works

printf( "%s\n%s\n",$0,$HOME); #this does not work

} else {

print $0;


}' param1_1.txt

I could use here echo command but I'm not sure how to use it properly.

I mean "properly" because the intention of this code is to serach for a particular string in a code and then when the string is found then a specific variable should be displaied in the next line after the string.

with simple text I can achieve this but not with variable.

Does anyone know how to correct this?

No comments:

Post a Comment