shell命令中三个箭头、两个箭头、一个箭头的区别

shell命令中<<
  • <<<代表一个字符串作为前面命令的标准输入
$ cat <<< 'hi there'
hi there
  • <<代表一个“here document”的开始
$ cat <hi
>there
>EOF
hi
there

EOF可以是任意字符串代表结束
"here document"在shell脚本中经常用来将一大段文字输入到一个文件

cat > some-file <
  • <将一个文件的内容作为命令的标准输入
$ cat < /etc/fstab
/dev/sda2               /boot   ext4            nosuid,noexec,nodev,rw,noatime,nodiratime       0 2
/dev/sda4               /       ext4            rw,noatime,nodiratime,  0 1
/dev/sdb5               /var    ext4            nosuid,noexec,nodev,rw,relatime 0 2

你可能感兴趣的:(shell)