I was working on a shell script where I came across this problem that I couldn't solve
The following command is supposed to find all shell files in /
.
PATHS_SHELL=$(sudo find / -name '*.sh')
If I execute the command without assigning it to a variable, it works just fine.
But when I assign it to PATHS_SHELL
. It gives me an endless loop with the following text
/home/kibnakamoto/workspace/Astrobee/scripts/daemon/astrobee/status_leds.sh: line 27: seq: command not found
/home/kibnakamoto/workspace/Astrobee/scripts/daemon/astrobee/status_leds.sh: line 159: sleep: command not found
/home/kibnakamoto/workspace/Astrobee/scripts/daemon/astrobee/status_leds.sh: line 27: seq: command not found
/home/kibnakamoto/workspace/Astrobee/scripts/daemon/astrobee/status_leds.sh: line 108: sleep: command not found
/home/kibnakamoto/workspace/Astrobee/scripts/daemon/astrobee/status_leds.sh: line 27: seq: command not found
/home/kibnakamoto/workspace/Astrobee/scripts/daemon/astrobee/status_leds.sh: line 124: sleep: command not found
/home/kibnakamoto/workspace/Astrobee/scripts/daemon/astrobee/status_leds.sh: line 27: seq: command not found
/home/kibnakamoto/workspace/Astrobee/scripts/daemon/astrobee/status_leds.sh: line 134: sleep: command not found
/home/kibnakamoto/workspace/Astrobee/scripts/daemon/astrobee/status_leds.sh: line 138: systemctl: command not found
/home/kibnakamoto/workspace/Astrobee/scripts/daemon/astrobee/status_leds.sh: line 27: seq: command not found
/home/kibnakamoto/workspace/Astrobee/scripts/daemon/astrobee/status_leds.sh: line 146: sleep: command not found
/home/kibnakamoto/workspace/Astrobee/scripts/daemon/astrobee/status_leds.sh: line 149: ps: command not found
/home/kibnakamoto/workspace/Astrobee/scripts/daemon/astrobee/status_leds.sh: line 149: grep: command not found
/home/kibnakamoto/workspace/Astrobee/scripts/daemon/astrobee/status_leds.sh: line 149: wc: command not found
/home/kibnakamoto/workspace/Astrobee/scripts/daemon/astrobee/status_leds.sh: line 150: [: : integer expression expected
/home/kibnakamoto/workspace/Astrobee/scripts/daemon/astrobee/status_leds.sh: line 27: seq: command not found
/home/kibnakamoto/workspace/Astrobee/scripts/daemon/astrobee/status_leds.sh: line 27: seq: command not found
/home/kibnakamoto/workspace/Astrobee/scripts/daemon/astrobee/status_leds.sh: line 159: sleep: command not found
/home/kibnakamoto/workspace/Astrobee/scripts/daemon/astrobee/status_leds.sh: line 27: seq: command not found
/home/kibnakamoto/workspace/Astrobee/scripts/daemon/astrobee/status_leds.sh: line 108: sleep: command not found
/home/kibnakamoto/workspace/Astrobee/scripts/daemon/astrobee/status_leds.sh: line 27: seq: command not found
/home/kibnakamoto/workspace/Astrobee/scripts/daemon/astrobee/status_leds.sh: line 124: sleep: command not found
/home/kibnakamoto/workspace/Astrobee/scripts/daemon/astrobee/status_leds.sh: line 27: seq: command not found
/home/kibnakamoto/workspace/Astrobee/scripts/daemon/astrobee/status_leds.sh: line 134: sleep: command not found
/home/kibnakamoto/workspace/Astrobee/scripts/daemon/astrobee/status_leds.sh: line 138: systemctl: command not found
/home/kibnakamoto/workspace/Astrobee/scripts/daemon/astrobee/status_leds.sh: line 27: seq: command not found
/home/kibnakamoto/workspace/Astrobee/scripts/daemon/astrobee/status_leds.sh: line 146: sleep: command not found
/home/kibnakamoto/workspace/Astrobee/scripts/daemon/astrobee/status_leds.sh: line 149: ps: command not found
/home/kibnakamoto/workspace/Astrobee/scripts/daemon/astrobee/status_leds.sh: line 149: grep: command not found
/home/kibnakamoto/workspace/Astrobee/scripts/daemon/astrobee/status_leds.sh: line 149: wc: command not found
/home/kibnakamoto/workspace/Astrobee/scripts/daemon/astrobee/status_leds.sh: line 150: [: : integer expression expected
/home/kibnakamoto/workspace/Astrobee/scripts/daemon/astrobee/status_leds.sh: line 27: seq: command not found
/home/kibnakamoto/workspace/Astrobee/scripts/daemon/astrobee/status_leds.sh: line 27: seq: command not found
/home/kibnakamoto/workspace/Astrobee/scripts/daemon/astrobee/status_leds.sh: line 159: sleep: command not found
/home/kibnakamoto/workspace/Astrobee/scripts/daemon/astrobee/status_leds.sh: line 27: seq: command not found
/home/kibnakamoto/workspace/Astrobee/scripts/daemon/astrobee/status_leds.sh: line 108: sleep: command not found
/home/kibnakamoto/workspace/Astrobee/scripts/daemon/astrobee/status_leds.sh: line 27: seq: command not found
/home/kibnakamoto/workspace/Astrobee/scripts/daemon/astrobee/status_leds.sh: line 124: sleep: command not found
/home/kibnakamoto/workspace/Astrobee/scripts/daemon/astrobee/status_leds.sh: line 27: seq: command not found
/home/kibnakamoto/workspace/Astrobee/scripts/daemon/astrobee/status_leds.sh: line 134: sleep: command not found
/home/kibnakamoto/workspace/Astrobee/scripts/daemon/astrobee/status_leds.sh: line 138: systemctl: command not found
/home/kibnakamoto/workspace/Astrobee/scripts/daemon/astrobee/status_leds.sh: line 27: seq: command not found
/home/kibnakamoto/workspace/Astrobee/scripts/daemon/astrobee/status_leds.sh: line 146: sleep: command not found
/home/kibnakamoto/workspace/Astrobee/scripts/daemon/astrobee/status_leds.sh: line 149: ps: command not found
/home/kibnakamoto/workspace/Astrobee/scripts/daemon/astrobee/status_leds.sh: line 149: wc: command not found
/home/kibnakamoto/workspace/Astrobee/scripts/daemon/astrobee/status_leds.sh: line 149: grep: command not found
/home/kibnakamoto/workspace/Astrobee/scripts/daemon/astrobee/status_leds.sh: line 150: [: : integer expression expected
/home/kibnakamoto/workspace/Astrobee/scripts/daemon/astrobee/status_leds.sh: line 27: seq: command not found
/home/kibnakamoto/workspace/Astrobee/scripts/daemon/astrobee/status_leds.sh: line 27: seq: command not found
/home/kibnakamoto/workspace/Astrobee/scripts/daemon/astrobee/status_leds.sh: line 159: sleep: command not found
/home/kibnakamoto/workspace/Astrobee/scripts/daemon/astrobee/status_leds.sh: line 27: seq: command not found
/home/kibnakamoto/workspace/Astrobee/scripts/daemon/astrobee/status_leds.sh: line 108: sleep: command not found
/home/kibnakamoto/workspace/Astrobee/scripts/daemon/astrobee/status_leds.sh: line 27: seq: command not found
/home/kibnakamoto/workspace/Astrobee/scripts/daemon/astrobee/status_leds.sh: line 124: sleep: command not found
/home/kibnakamoto/workspace/Astrobee/scripts/daemon/astrobee/status_leds.sh: line 27: seq: command not found
/home/kibnakamoto/workspace/Astrobee/scripts/daemon/astrobee/status_leds.sh: line 134: sleep: command not found
/home/kibnakamoto/workspace/Astrobee/scripts/daemon/astrobee/status_leds.sh: line 138: systemctl: command not found
Before this endless output, the output is many of the shell file paths which is the expected and correct output. e.g.
/usr/src/linux-headers-5.15.0-48/tools/testing/selftests/netfilter/ipvs.sh
/usr/src/linux-headers-5.15.0-48/tools/testing/selftests/netfilter/ipip-conntrack-mtu.sh
/usr/src/linux-headers-5.15.0-48/tools/testing/selftests/netfilter/conntrack_tcp_unreplied.sh
/usr/src/linux-headers-5.15.0-48/tools/testing/selftests/netfilter/nft_fib.sh
/usr/src/linux-headers-5.15.0-48/tools/testing/selftests/netfilter/nft_nat_zones.sh
/usr/src/linux-headers-5.15.0-48/tools/testing/selftests/netfilter/nft_meta.sh
/usr/src/linux-headers-5.15.0-48/tools/testing/selftests/netfilter/nft_zones_many.sh
/usr/src/linux-headers-5.15.0-48/tools/testing/selftests/netfilter/nft_concat_range.sh
/usr/src/linux-headers-5.15.0-48/tools/testing/selftests/netfilter/nf_nat_edemux.sh
/usr/src/linux-headers-5.15.0-48/tools/testing/selftests/netfilter/nft_nat.sh
/usr/src/linux-headers-5.15.0-48/tools/testing/selftests/netfilter/conntrack_icmp_related.sh
/usr/src/linux-headers-5.15.0-48/tools/testing/selftests/livepatch/test-shadow-vars.sh
/usr/src/linux-headers-5.15.0-48/tools/testing/selftests/livepatch/test-livepatch.sh
I am using Ubuntu 22.04.
/home/kibnakamoto/workspace/Astrobee/scripts/daemon/astrobee/status_leds.sh
. I am guessing that you are later using the variable, most probably using it without quoting it correctly, and that produces the errors, but we can't help without seeing the rest of the script or, even better, a small part of the script that we can run to reproduce the errors.readarray -td '' sh_scripts < <(sudo find / -name '*.sh' -type f -print0)
to assign the list of the paths of regular files with names ending in.sh
to a variable.PATHS_SHELL=$(sudo find / -name '*.sh')
doesn't make any sense.$PATH
as a variable to index into$PATHS_SHELL
?cat x y >> x
. Thank you.