So, I have a file which contains a list of hundreds of files that need to be deleted from various directories. I figured the easiest method would be to create a batch file but I'm not having great success.
#/bin/bash
rm "/home/e-smith/files/users/bill/Maildir/cur/1392373930.28512.comp01:2,S"
rm "/home/e-smith/files/users/ted/Maildir/cur/1420726198.17690.comp01:2,S"
But when I run the script with
./myfile.txt
I get
rm: cannot remove '/home/e-smith/files/users/bill/Maildir/cur/1392373930.28512.comp01:2,S\r': no such file or directory
rm: cannot remove '/home/e-smith/files/users/ted/Maildir/cur/1420726198.17690.comp01:2,S\r': no such file or directory
I don't understand where the \r
is coming from, I'm guessing it's a carriage return but it appends itself to the command.
What is the correct method/syntax for an exercise like this?
This is due to the line-endings that Windows uses (\r\n
).
You can remove thes via vi
:
$ vi myfile.txt
<ESC>
:set fileformat=unix
:wq
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments