Folder name with spaces

Hello,
When I give:

rm -f /usr/local/tomcat/temp_img/\Images\ for\ UAT/0918-721-163-001-4C-P_04.jpg

, the file is being deleted.

I am trying to do the same in a script as follows:

Step 1:
A file named del.txt will have the following (list of files to be deleted):

/usr/local/tomcat/temp_img/\Images\ for\ UAT/0918-721-163-001-4C-P_04.jpg

Step 2: The script

for fname in `cat del.txt`
do
        rm -f echo $fname
done

As I pass the line from del.txt in a FOR loop, the fname is set to following:

  1. /usr/local/tomcat/temp_img/\Images\
  2. for\
  3. UAT/0918-721-163-001-4C-P_03.jpg

Hence the file is not being deleted. I tried the rm command within quotes

'rm -f echo $fname'
`rm -f echo $fname`
"rm -f echo $fname"

and also tried to put the test in del.txt within quotes. But no luck. Please help me.

Thanks,
risshanth

while read fname
do
 rm -f echo "$fname"
done < del.txt

Thank you so much !!!!!!

:b: And the spaces won't need to be escaped in the del.txt file.

Surely it's:

rm -f "$fname"

Andrew

I guess that echo was left over from testing.

But rm -f won't complain about it.

I did the testing after removing the escape char from del.txt
And, the echo was from my testing only

Thank you guys