1822430 Members
2902 Online
109642 Solutions
New Discussion юеВ

Re: awk,print

 
System Dude_1
Frequent Advisor

awk,print

Dear Friend,

how to pass an argument as below :
cat test.log|grep -v "*"|awk '{print '"TRY",$1"-"$2,">","/home/"$1".LOG".$3'}' > test1.log

I've got this error :

awk: The statement cannot be correctly parsed.
Performance Issue on HP-UX 10.20
4 REPLIES 4
Maarten van Rossen
Occasional Advisor

Re: awk,print

I think it should be like this:
awk '{print '"TRY",$1"-"$2,">","/home/"$1".LOG."$3}'

Notice that I removed "'" before "}" and that I moved the "." before $3

Hope this helps
Deepak Extross
Honored Contributor

Re: awk,print

You'll have to drop the single quite just after the "print" as well.

awk '{print "TRY",$1"-"$2,">/home/"$1".LOG".$3}'
Gadi
Advisor

Re: awk,print

hi,
Try this:
cat test.log|grep -v "*"|awk '{print '"TRY",$1"-"$2,">","/home/"$1".LOG",$3'}' > test1.log

*Note:
I put "," instead of "." - befor the last $3.

I hope it helps.
Ceesjan van Hattum
Esteemed Contributor

Re: awk,print

usage of printf is to prefer above print inside of awk.

awk '{printf "TRY %s,%s > /home/%s.LOG.%s",$1,$2,$1,$3 }' >test1.log

..or something like it.
Your quoting of print goes wrong: print '"..."..".."' inside of body...

Regards,
Ceesjan