I am stuck with weird issue. Process substitution is not working when it's been called from bash script, however it work when I shoot it from terminal.
Here is example: While running over terminal.
terminal>echo "$x"
a b c
d e f
g h i
j k l
terminal>echo "$y"
1
2
3
4
terminal>paste <(echo "$x") <(echo "$y") -d' '
a b c 1
d e f 2
g h i 3
j k l 4
Here is example: Sample script
#!/bin/bash
x='a b c
d e f
g h i
j k l'
y='1
2
3
4'
paste <(echo "$x") <(echo "$y") -d' '
When I above script , I get following error:
test: line 12: syntax error near unexpected token `('
test: line 12: `paste <(echo "$x") <(echo "$y") -d' ''
Following are the details of shell I am using.
echo $SHELL
/bin/bash
bash --version
GNU bash, version 4.2.47(1)-release (x86_64-suse-linux-gnu)
Is there any alternate way to bypass this issue ? Not necessarily I want to stick to process substitution.
Desired o/p:
a b c 1
d e f 2
g h i 3
j k l 4
Process substitution does not work when bash is in POSIX mode. Please disable POSIX and try again.
To disable: This will cause process substitution to work .
set +o posix
To enable: : This will cause process substitution not to work.
set -o posix
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With