I need to delete some files in a directory using a list. For example I have this file list:
list.txt:
0NM.pdb
POR.pdb
0UA.pdb
AU7.pdb
In /home/my_directory/
I have this file
U6Y.pdb
0NM.pdb
POR.pdb
AR2.pdb
0UA.pdb
AU7.pdb
At the end in the directory i should have only this:
U6Y.pdb
AR2.pdb
I have show some other discussion for this problem and I try to use some different script but all gave me the same result:
rm: impossibile rimuovere "ONM.pdb\r": File o directory non esistente
rm: impossibile rimuovere "POR.pdb\r": File o directory non esistente
rm: impossibile rimuovere "OUA.pdb\r": File o directory non esistente
rm: impossibile rimuovere "AU7.pdb\r": File o directory non esistente
I try to use these different script:
-> printf "%s\n" $(<list.txt) | xargs -I@ rm @
-> while read name; do rm "$name"; done < /home/list.txt
-> while read -r filename; do rm "$filename"; done </home/list.txt
-> xargs -a /home/list.txt -d'\n' rm
Why all these give me the same error? Why does "\r"
appear at the end of the file names to be deleted?