It isn't entirely clear yet, but the chances are very high that you either have an incorrect shebang line at the top of the script:
#!/bin/sh
or you are using sh script.sh
instead of bash script.sh
while testing it, or you have SHELL=/bin/sh
or something similar set in the environment. Your failure is on the process substitution code. When Bash is run as sh
(in POSIX mode), then process substitution is not available:
- Process substitution is not available.
You need to write:
#!/bin/bash
temp=$(comm -12 <(sort -u /home/xyz/a.csv1) <(sort -u /home/abc/tempfile) | wc -l)
echo $temp
or even simply:
#!/bin/bash
comm -12 <(sort -u /home/xyz/a.csv1) <(sort -u /home/abc/tempfile) | wc -l
which will achieve the same effect as the capture followed by the echo. When testing, use bash -x script.sh
or bash script.sh
.
Deciphering the indecipherable comment
In an indecipherable comment, the information appears to include:
BASH=/bin/sh
BASHOPTS=cmdhist:extquote:force_fignore:hostcomplete:interactive_comments:progco?mp:promptvars:sourcepath
BASH_ALIASES=()
BASH_ARGC=()
BASH_ARGV=()
BASH_CMDS=()
BASH_LINENO=([0]="0")
BASH_SOURCE=([0]="a.sh")
BASH_VERSINFO=([0]="4" [1]="1" [2]="2" [3]="1" [4]="release" [5]="x86_64-redhat-linux-gnu")
BASH_VERSION='4.1.2(1)-release'
CVS_RSH=ssh
SHELL=/bin/bash
SHELLOPTS=braceexpand:hashall:interactive-comments:posix
SHLVL=2
Note that BASH=/bin/sh
and SHELLOPTS=braceexpand:hashall:interactive-comments:posix
. Either or both of these might be a major part of the problem.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…