`awk "{print $2}" file` prints whole lines instead of the second column.
IntermediateTroubleshootingTroubleshooting: quoting, expansion and tool-input bugs
Answer
Likely causes → Double quotes let the shell expand $2 first (to empty, or the script's second argument), so awk receives {print }, which prints the whole line.
Diagnose → set -x shows awk '{print }' file.
Fix → Single-quote awk programs and pass shell values with -v:
awk -v col="$col" '{print $col}' file
Prevent → Always single-quote awk, sed and jq programs. ShellCheck warns about this pattern.
More on Troubleshooting: quoting, expansion and tool-input bugs
`bash: [: too many arguments`Beginner`bash: [: =: unary operator expected`BeginnerA disk check fails with `[: 93%: integer expression expected`Beginner`rm $file` fails with `rm: cannot remove 'monthly': No such file or directory` and `rm: cannot remove 'report.csv'`.BeginnerA cleanup script logs `cp: cannot stat '/var/log/app/*.log': No such file or directory` on quiet days.Beginner`echo "start" > $logfile` fails with `bash: $logfile: ambiguous redirect`Intermediate