파일 이름에 포함 할 수있는 문자를 신경 쓰지 않고 파일 목록을 반복하면서 null 문자로 구분 된 목록을 사용합니다. 이 코드는 더 잘 설명 할 것입니다. 파일에서 읽을 때Bash 루프를 통해 널로 구분 된 문자열 읽기.
# Set IFS to the null character to hopefully change the for..in
# delimiter from the space character (sadly does not appear to work).
IFS=$'\0'
# Get null delimited list of files
filelist="`find /some/path -type f -print0`"
# Iterate through list of files
for file in $filelist ; do
# Arbitrary operations on $file here
done
다음 코드는 작동하지만 변수가 포함 텍스트에서 읽을 필요가있다. 배쉬에서
while read -d $'\0' line ; do
# Code here
done < /path/to/inputfile
bash 변수에 null 문자를 저장할 수 없다고 생각합니다. 적어도, 나는 그것을 할 방법을 찾지 못했습니다 ... –