0

I don't know ,why I can't print from to file. My command:

awk 'BEGIN{print "af">file}'

Error:

fatal: expression for `>>' redirection has null string value
2

file needs to be in quotes else awk will attempt to parse file as a variable rather than a string:

 awk 'BEGIN{print "af">"file"}'
  • ... or else file has to be assigned a value: awk 'BEGIN {file="mytest"; print "af">file}'. – Scott Sep 2 '15 at 5:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.