seems simple but i've not been successfull in adding the value of a Variable to a every line of a file using AWK & printf
i've come up with the following, but it's not working.
--- mydatafile.dat
e.g. of data in file:
cau_actvty_fa_lrf.ksh
fan_soco_fa.ksh
ny_sum_lst.ksh
etc....
myvar_path=$PWD
awk -v PATH=$myvar_path '{printf("%s\nPATH",$0)}' mydatafile.dat
output is to be: value of $PWD before each file name
awk -v PATH="$myvar_path" '{printf( PATH "%s\n",$0)}' mydatafile.dat
thanks...
but how would i then put a / after the value of PATH which will be between the filename and it's path it doesn't seem that PATH gets a formating expression since it's comming before the formatting expressions.... bear with me as i'm still learning the nuances of awk...
awk -v PATH="$myvar_path" '{printf( PATH "%s\n",$0)}' mydatafile.dat
i figured out another way too, but a bit more involved
awk '{printf("%s/%s\n","'"${myvar_path}"'",$1)}' mydatafile.dat
this way i was able to insert a / after the value of ${myvar_path}
Thanks again for your time.
Just put one there:
awk -v PATH="$myvar_path" '{printf( PATH "/%s\n",$0)}' mydatafile.dat
PATH is part of the format string.
Awesome.... i didn't realize you could put something before the %s
Thanks again, little by little , my little understanding is getting bigger.
thanks.