I have a simple bash script that looks like this, which adds two "printer" processes that print words in a loop to an array and executes them, storing their process IDs. I am trying to user process substitution to filter out a piece of text that gets printed, but I keep getting the error grep: <(./usr/bin/printscript2.sh): No such file or directory
The scripts for the printer processes are similar but printscript1 just has some different words, so I'll add the code for printscript2 below the parent process.
#!/bin/bash
# Setup array for the commands we wish to execute
procs_arr=()
procs_arr+=("/usr/bin/printscript1.sh")
procs_arr+=("grep -v FILTERMEPLEASEENDTHISMISERY <(/usr/bin/printscript2.sh)")
num_procs=${#procs_arr[@]}
echo "num_procs = $num_procs"
# Run the commands and store pids to an array
pids=()
for (( i=0; i<"$num_procs"; i++ )); do
echo "cmd = ${procs_arr[$i]}"
${procs_arr[$i]} &
pids+=("$!")
echo " pid = ${pids[$i]}"
done
while true; do
sleep 1000
done
exit 0
!/bin/bash
sleep 3
while true; do
sleep 5
echo "parrot"
sleep 5
echo "FILTERMEPLEASEENDTHISMISERY"
sleep 5
echo "socks"
done
I executed the same command using process substitution locally in the shell (i.e. ran "grep -v FILTERMEPLEASEENDTHISMISERY <(/usr/bin/printscript2.sh)" in bash directly) and it worked as intended, meaning the string was filtered out from the console prints. I'm not sure if there's some special formatting I'm missing here. I also tried to use escape characters so putting a backslash '' in front of '<', '(', and ')' and got the same error grep: \<\(/usr/bin/printscript2.sh\): No such file or directory
. Is this a function that is only supposed to be supported when directly done in a bash shell, or am I typing something incorrectly?