I want to add this awk command on my script but keep getting error. I have put inside ” ” but still getting error.
system("awk -F"\t" '{ for ( i=1; i<=2; i++ ) { printf "%s\t", $i } printf "\n"; }' myfile file2"};
the errors are
String found where operator expected
at host_parse line 21, near “t” ‘{ for
( i=1; i<=2; i++ ) { printf “”Unquoted string “a” may clash with
future reserved word at myfile line
58.Unquoted string “a” may clash with
future reserved word at myfile line
58.syntax error at myfile line 21, near
“” awk -F”\”
Thanks.
One of the trickiest parts about using the
systemcommand is using quotes in a way that will get the correct command passed to the operating system. Perl’sq//construction can be very helpful for this: