1
텍스트 파일에서 파일 이름을 읽고 디렉토리에 파일이 있는지 확인하기위한 간단한 bash 스크립트를 작성했습니다. 이 파일은 정상적으로 작동하지만 모든 파일을 파싱 한 후에 무한 루프에 빠지게됩니다.파일을 읽는 중 Bash 스크립트 무한 루프
The file '.gz' does not exist.
The file '.gz' does not exist.
The file '.gz' does not exist.
The file '.gz' does not exist.
The file '.gz' does not exist.
The file '.gz' does not exist.
etc.
내가 해결책은 아주 간단합니다 알고 있지만, 그것은 아침의 대부분을 나를 귀찮게 됐어요 :
#!/bin/bash
if [ "$1" = "" ]; then
echo "No input file to parse given. Give me an input file and make sure the corresponding .gz files are in the folder."
else
file=$1
echo "Loaded $file."
while read -r line
currentfile="$line.gz"
do
if [ -f $currentfile ]; then
echo "The file '$currentfile' exists."
else
echo "The file '$currentfile' does not exist."
fi
done < "$file"
fi
은 그리고이 모든 파일 후 루프 출력이 나열되어 있습니다! 어떤 도움을 주셔서 감사합니다!
많은 친절한 선생님! – ScubaChris
@ScubaChris : 그냥 upvote/대답을 수락 :) – choroba