The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 12:04 PM
How to delete multiple space or tabs from a read only file bisla.yogender Shell Programming and Scripting 6 05-14-2008 07:38 AM
Space problem in files vibhor_agarwali UNIX for Dummies Questions & Answers 6 05-22-2007 02:43 AM
Script to delete all data from multiple files uni_ajay_r Shell Programming and Scripting 5 03-29-2006 11:05 AM
Need a script to delete multiple files navycow UNIX for Dummies Questions & Answers 3 01-16-2006 02:50 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-20-2005
umen umen is offline
Registered User
  
 

Join Date: Aug 2005
Posts: 239
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?
  #2 (permalink)  
Old 09-20-2005
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
Supporter
  
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,350
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.
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:06 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0