The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Multiple Files Renaming with space nazri76 UNIX for Dummies Questions & Answers 13 10-04-2008 09:04 AM
How to delete multiple space or tabs from a read only file bisla.yogender Shell Programming and Scripting 6 05-14-2008 04:38 AM
Space problem in files vibhor_agarwali UNIX for Dummies Questions & Answers 6 05-21-2007 11:43 PM
Script to delete all data from multiple files uni_ajay_r Shell Programming and Scripting 5 03-29-2006 08:05 AM
Need a script to delete multiple files navycow UNIX for Dummies Questions & Answers 3 01-16-2006 11:50 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 09-19-2005
Registered User
 

Join Date: Aug 2005
Posts: 229
when I try to run rm on multiple files I have problem to delete files with space

Hello
when I try to run rm on multiple files I have problem to delete files with space.
I have this command :
find . –name "*.cmd" | xargs \rm –f

it doing the work fine but when it comes across files with spaces like : "my foo file.cmd"
it refuse to delete it
why?
Reply With Quote
Forum Sponsor
  #2  
Old 09-20-2005
blowtorch's Avatar
Supporter
 
Join Date: Dec 2004
Location: Singapore
Posts: 2,328
In this case when rm encounters a filename such as "my foo file.cmd", the space seperated words in the file will be treated as different files. So rm will try to remove files named "my", "foo", and "file.cmd", which it will not find.

A workaround for this will be:
Code:
find . -name "*.cmd" -exec rm {} \;
This will spawn as many 'rm' processes as there are files, but it will get the job done.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 10:14 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0