when I try to run rm on multiple files I have problem to delete files with space


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers when I try to run rm on multiple files I have problem to delete files with space
# 1  
Old 09-20-2005
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  
Old 09-20-2005
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.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Run script on multiple files

Hi Guys, I've been having a look around to try and understand how i can do the below however havent come across anything that will work. Basically I have a parser script that I need to run across all files in a certain directory, I can do this one my by one on comand line however I... (1 Reply)
Discussion started by: mutley2202
1 Replies

2. UNIX for Dummies Questions & Answers

How To Delete Multiple Files At Once?

I Want to delete the following files together,what command should i pass for that? (Note:- All Start With .) .bash_logout .bashrc .bash_profile .rtorrent.rc ... (3 Replies)
Discussion started by: anime12345
3 Replies

3. Shell Programming and Scripting

Run script on multiple files

I have a script that I need to run on one file at a time. Unfortunately using for i in F* or cat F* is not possible. When I run the script using that, it jumbles the files and they are out of order. Here is the script: gawk '{count++; keyword = $1} END { for (k in count) {if (count == 2)... (18 Replies)
Discussion started by: newbie2010
18 Replies

4. Shell Programming and Scripting

Run one script on multiple files and print out multiple files.

How can I Run one script on multiple files and print out multiple files. FOR EXAMPLE i want to run script.pl on 100 files named 1.txt ....100.txt under same directory and print out corresponding file 1.gff ....100.gff.THANKS (4 Replies)
Discussion started by: grace_shen
4 Replies

5. UNIX for Dummies Questions & Answers

Run one script on multiple files and print out multiple files.

How can I run the following command on multiple files and print out the corresponding multiple files. perl script.pl genome.gff 1.txt > 1.gff However, there are multiples files of 1.txt, from 1----100.txt Thank you so much. No duplicate posting! Continue here. (0 Replies)
Discussion started by: grace_shen
0 Replies

6. Shell Programming and Scripting

Bash Scipting (New); Run multiple greps > multiple files

Hi everyone, I'm new to the forums, as you can probably tell... I'm also pretty new to scripting and writing any type of code. I needed to know exactly how I can grep for multiple strings, in files located in one directory, but I need each string to output to a separate file. So I'd... (19 Replies)
Discussion started by: LDHB2012
19 Replies

7. Shell Programming and Scripting

Perl Script to find the disk usage and to delete the files which is consuming more space

Hi All, I have written a script to check the file system usage and to delete the files which is consuming more space.Please check whether the script is corrcet #Script Starts here #!/usr/local/bin/perl #Program to find the disk space and to delete the older files #Checks the type of OS... (8 Replies)
Discussion started by: arunkarthick
8 Replies

8. UNIX for Dummies Questions & Answers

Copy multiple files with space to folder

Please help , I am in an urgent need, Please help nawk '{for(i=1;i<=NF;i++){printf("%s\n",$i)}}' filename | sed 's/.*com//' | nawk '/pdf/ {printf("F:%s\n",$0)}' | while read line; do mv $line /images/; done the above script works for without spaces but,My path is also having some space... (3 Replies)
Discussion started by: umapearl
3 Replies

9. Shell Programming and Scripting

How to run multiple awk files

I'm trying some thing like this. But not working It worked for bash files Now I want some thing like that along with multiple input files by redirecting their outputs as inputs of next command like below Could you guyz p0lz help me on this #!/usr/bin/awk -f BEGIN { } script1a.awk... (2 Replies)
Discussion started by: repinementer
2 Replies

10. UNIX for Dummies Questions & Answers

Multiple Files Renaming with space

Hi, I need help how to renaming multiple file. The original file look like this; Test Monday.txt Test Wednesday.txt Test July.txt I have more than hundred file in the directory. How i want to rename all file to a new file name in one time? The new file maybe the same name e.g.... (13 Replies)
Discussion started by: nazri76
13 Replies
Login or Register to Ask a Question