0

I tried set separator -F: in here.

awk -F "{print $1}" /etc/passwd

But its not effects...

Then I found out use '{…}' instead of "{…}'. It's works good!

So what's difference in '{…}' and "{…}" for awk? Thank you!!

dingding
  • 13
  • 1
  • 3
  • Your command line is missing the `:` — which leads to problems. Use `awk -F: '{print $1}' /etc/passwd`. With double quotes around the script, the `$1` is expanded — to nothing — so the `print` prints the whole line. Use single quotes around `awk` scripts on the command line unless you're confident in handling the difference between single and double quotes in the shell. – Jonathan Leffler Feb 11 '18 at 02:00
  • It's not awk that has a distinction between quote types, it's bash. – John Kugelman Feb 11 '18 at 02:01
  • Emmm... I forgot type a : about opt of -F. Sorry – dingding Feb 11 '18 at 03:38

0 Answers0