쉘 무한 루프 찾기 명령

쉘 무한 루프 찾기 명령

쉘 스크립트를 작성 중인데 해결할 수 없는 문제가 발생했습니다.

다음 명령으로 이를 찾아야 합니다 /.

PATHS_SHELL=$(sudo find / -name '*.sh')                                                          

변수에 할당하지 않고 명령을 실행하면 정상적으로 작동합니다. 하지만 에 할당하면 PATHS_SHELL다음 텍스트와 함께 무한 루프가 발생합니다.

/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

이 끝없는 출력 이전에는 예상되고 올바른 출력인 여러 셸 파일 경로가 출력되었습니다. 예를 들어

/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

우분투 22.04를 사용하고 있습니다.

답변1

$PATH문자열을 색인화하기 위해 예약된 변수를 사용한 것 같습니다 $PATHS_SHELL. 이 변수는 명령을 검색할 디렉터리 목록을 보유하므로 덮어쓰면 더 이상 스크립트 명령이 발견되지 않습니다. 따라서 명령에 대한 오류를 찾을 수 없습니다.

관련 정보