shell脚本错误

小弟在学习linux的shell中遇到一个问题。
在终端下,输入命令
cat /etc/passwd | awk '{FS=":"} {print "The " NR " count is " $1}'
得到结果
The 1 count is root:x:0:0:root:/root:/bin/bash
The 2 count is daemon
The 3 count is bin
The 4 count is sys
.........
但是小弟把上面代码写入到shell脚本中,文件明p.sh
#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
export PATH
`cat /etc/passwd | awk '{FS=":"} {print "The " NR " count is " $1}'`
然后在终端输入命令
sh p.sh
报如下错误
p.sh: 4: The: not found
输入调试命令
sh -x p.sh
报错
+ PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/home/zhangyaning/bin
+ export PATH
+ cat /etc/passwd
+ awk {FS=":"} {print "The " NR " count is " $1}
+ The 1 count is root:x:0:0:root:/root:/bin/bash The 2 count is daemon The 3 count is bin The 4 count is sys The 5 count is sync The 6 count is games The 7 count is man The 8 count is lp The 9 count is mail The 10 count is news The 11 count is uucp The 12 count is proxy The 13 count is www-data The 14 count is backup The 15 count is list The 16 count is irc The 17 count is gnats The 18 count is nobody The 19 count is libuuid The 20 count is syslog The 21 count is klog The 22 count is hplip The 23 count is avahi-autoipd The 24 count is gdm The 25 count is saned The 26 count is pulse The 27 count is messagebus The 28 count is polkituser The 29 count is avahi The 30 count is haldaemon The 31 count is zhangyaning The 32 count is alex The 33 count is arod
p.sh: 1: The: not found
在终端输入 echo $PATH
结果:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
小弟刚学习shell不久,google了很久没有找到原因。

你可能感兴趣的:(linux,脚本,Google,bash)