I'm having trouble to understand the difference of behavior of awk when using field separators passed through the command line and using FS=":"
in a script.
I thought using -F
to supply the field separator and using the FS
variable in awk were the same thing.
But if I do:
awk -F: '{}' /etc/passwd
it prints nothing as expected because of the empty action ({}
).
And also, if I put on a script:
#!/usr/bin/awk -f
{}
no lines are printed to the output, as expected.
Now, if I put the field separator in the script, as in:
#!/usr/bin/awk -f
FS=":";
{}
it prints all lines again!
So, I want to suppress the default print action in a script, because I am going to do some computation in the action and print the result later in an END
section. How can I do that without awk printing all the lines first?