b33713
August 26, 2009, 8:08am
1
i want to use getline to read command output to a var
but the command i want to run is composed of a string and a variable,example:
echo "" | awk 'BEGIN{myfile="anyfilename"}{"ls -l "myfile | getline a;print a}'
and i got a error
sh: anyfilename: command not found
it seems awk just ignored the string "ls -l "
so,whats the right syntax ,thanks
It seems that the file "anyfilename" doesn't exist in the actual directory.
BTW the echo statement is redundant here.
Regards
b33713
August 26, 2009, 9:00am
3
it run "anyfilename" as a command,not "ls -l anyfilename" that what i want
anyfilename just for example,it can be any exist file
i use gawk btw
any help?
This works fine for me:
awk 'BEGIN{myfile="anyfilename";"ls -l " myfile | getline a;print a}'
b33713
August 26, 2009, 9:29am
5
it doesn't work on RHEL...
so is it a dead end?....