所以,命令:
dmesg | grep 'Attached SCSI disk' | awk '{ print $5}'
当直接从 shell 执行时,工作正常,输出:
[sdb]
[sdc]
[sda]
但是,当我启动它时:
sh -c "dmesg | grep 'Attached SCSI disk' | awk '{ print $5}'"
# or
bash -c "dmesg | grep 'Attached SCSI disk' | awk '{ print $5}'"
我得到:
[ 2.460353] sd 1:0:0:0: [sdb] Attached SCSI disk
[ 2.461348] sd 2:0:0:0: [sdc] Attached SCSI disk
[ 2.464181] sd 0:0:0:0: [sda] Attached SCSI disk
这清楚地表明最后一个管道尚未执行。
我究竟做错了什么?