Bash:语法错误:重定向意外

我在脚本中这样做:
read direc <<< $(basename `pwd`)

我得到:

Syntax error: redirection unexpected

在ubuntu机器

/bin/bash --version
GNU bash,version 4.0.33(1)-release (x86_64-pc-linux-gnu)

而我不会得到这个错误在另一个suse机器:

/bin/bash --version
GNU bash,version 3.2.39(1)-release (x86_64-suse-linux-gnu)
copyright (C) 2007 Free Software Foundation,Inc.

为什么会出错?

你的脚本引用/ bin / bash或/ bin / sh在它的hash bang行吗? Ubuntu中的认系统shell是 dash,而不是 bash,所以如果你有#!/ bin / sh,那么你的脚本将使用不同的shell。破折号没有<<<重定向运算符。

相关文章

用的openwrt路由器,家里宽带申请了动态公网ip,为了方便把2...
#!/bin/bashcommand1&command2&wait从Shell脚本并行...
1.先查出MAMP下面集成的PHP版本cd/Applications/MAMP/bin/ph...
1、先输入locale-a,查看一下现在已安装的语言2、若不存在如...
BashPerlTclsyntaxdiff1.进制数表示Languagebinaryoctalhexa...
正常安装了k8s后,使用kubect工具后接的命令不能直接tab补全...