Never use a shebang to call awk as that has no worthwhile benefit over simply calling awk within your shell script but robs you of the ability to separate arguments passed to your shell script into values for the shell to process, values for awk to process use -v
, values for awk to process using assignments at the end of the script and file names for awk to run on.
Just write:
#!/usr/bin/env bash
awk -F':' '
whatever
' /etc/passwd
so that if you had to you could trivially tweak it to:
#!/usr/bin/env bash
sort "$1" |
awk -F':' -v foo="$2" '
whatever
' - FS="$3" "$4"
or whatever else you need to do to use the arguments passed to your shell script most appropriately.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…