1
为什么使用双引号将awk的动作语句括起来与使用单引号将它们括起来相比会产生不同的结果?
如果我使用单引号将awk的action语句括起来,它将按预期工作: $ dpkg -l | grep "linux\-[a-z]*\-" | awk {'print $2'} linux-headers-3.13.0-27 linux-headers-3.13.0-27-generic linux-headers-3.14.4-031404 linux-headers-3.14.4-031404-generic linux-headers-generic linux-image-3.13.0-27-generic linux-image-3.14.4-031404-generic linux-image-extra-3.13.0-27-generic linux-image-generic linux-libc-dev:i386 linux-sound-base 但是,如果我使用双引号将其引起来,它将打印整行而不是特定的列/字段: $ dpkg -l | grep "linux\-[a-z]*\-" | awk {"print $2"} ii linux-headers-3.13.0-27 3.13.0-27.50 all Header files related to Linux kernel version 3.13.0 ii linux-headers-3.13.0-27-generic 3.13.0-27.50 i386 Linux …