Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Bash &引用;预期标记“附近出现语法错误”;使用进程替换_Bash_Shell_Process Substitution - Fatal编程技术网

Bash &引用;预期标记“附近出现语法错误”;使用进程替换

Bash &引用;预期标记“附近出现语法错误”;使用进程替换,bash,shell,process-substitution,Bash,Shell,Process Substitution,这是一个有点尴尬的问题,但我找不到错误。我正在尝试进行进程替换。这是我的密码 while read compareFile1 <&3 && read compareFile2 <&4; do echo compareFile1 echo compareFile2 done 3< <(tail -n+4 test2.txt) 4< <(tail -n+4 test2.txt) while read compareFile1进程

这是一个有点尴尬的问题,但我找不到错误。我正在尝试进行进程替换。这是我的密码

while read compareFile1 <&3 && read compareFile2 <&4; do 
echo compareFile1
echo compareFile2
done 3< <(tail -n+4 test2.txt) 4< <(tail -n+4 test2.txt)

while read compareFile1进程替换在POSIX sh中不是可用的功能(
#!/bin/sh
,也可以通过
sh yourscript
调用);尽管将这个问题标记为“bash”,但您显然是在用非bash shell执行脚本(或者进入可移植模式,如
set-oposix


改用bash;因此,把
#/bin/bash
在脚本的开头,或者,如果手动指定解释器,则使用
bash-yourscript
调用它。

您在
/bin/sh
中使用的是bash-only语法。我想我使用bash是因为我在mac中工作,bash是默认的,而您的交互式shell是否是bash与脚本是否也在bash中运行无关。你剧本的第一行是什么?它是以
#开头的吗/bin/sh
#/bin/bash
,还是别的什么?您使用什么命令启动该脚本?您正在运行
/scriptname
sh scriptname
bash scriptname
,还是其他什么?是的,我理解我的错误,我是通过sh命令运行程序的,而且没有#/文件开头的bin/bash命令。谢谢你让我大开眼界。
sh.sh: line 7: syntax error near unexpected token `<'
sh.sh: line 7: `done 3< <(tail -n+4 test2.txt) 4< <(tail -n+4 test2.txt)