리눅스 파일이름으로 된 목록을 불러와서 해당 파일 지우기

지울 파일들의 이름을 files_to_remove.txt에 한줄에 하나씩 넣어놓고, 다음 명령들을 이용해서 일괄적으로 지운다.

Bash

Bash의 명령어 대치 (Command Substitution) 기능을 이용한 방법

rm -rf `cat /path/to/files_to_remove.txt`

xargs

파일명의 공백, 특수문자도 처리가능.

xargs -d '\n' -a files_to_remove.txt rm
 cat files_to_remove.txt | xargs rm

스크립트

while read files_to_remove.txt ; do rm "$filename" ; done < files.lst

펄(perl)

perl -lne 'unlink' files_to_remove.txt

참고

연결문서


CC Attribution-Noncommercial-Share Alike 4.0 International 별도로 명시하지 않을 경우, 이 페이지의 내용은 다음 라이선스에 따라 사용할 수 있습니다: CC Attribution-Noncommercial-Share Alike 4.0 International
tech/리눅스_목록의_파일_지우기.txt · 마지막으로 수정됨 저자 127.0.0.1