Results 1 to 10 of 10
i want something like:
sudo rm -r < sudo find / -name rhythm*
or i may do:
sudo find / -name rhythm* > rhyth.txt
rm -r < rhyth.txt
i.e. i ...
- 08-05-2011 #1Just Joined!
- Join Date
- Jan 2011
- Location
- Ukraine, Donetsk
- Posts
- 5
linux rm find concatenate
i want something like:
sudo rm -r < sudo find / -name rhythm*
or i may do:
sudo find / -name rhythm* > rhyth.txt
rm -r < rhyth.txt
i.e. i want to find some files and delete them automatically.
but i don't know syntax.
how to do this?
- 08-05-2011 #2Two notes:Code:
find <PATH> -type f -name "rhythm"
1) You will need to replace <PATH>. It is not necessary to use / unless these rhyth files were scattered all over the filesystem.
2) If the above command provides a list, that you can verify, then run it again and add a -deleteYou must always face the curtain with a bow.
- 08-05-2011 #3Just Joined!
- Join Date
- Jan 2011
- Location
- Ukraine, Donetsk
- Posts
- 5
thanks
works fine but tooo slow :
sudo find / -name rhythm* -delete,
how to do this with rm?
i.e. i want that rm reads list of files for deletion:
rm -r < rhyth.2
- 08-06-2011 #4
Can be done in one line, but if I already have the list in a file I usually do something like
Make sure it's what you want to do first, there's no "unrm". Not easily, anyway.Code:cat rhyth.2|while read file do rm -r $file done
- 08-06-2011 #5Just Joined!
- Join Date
- May 2006
- Posts
- 1
I think what you are looking for is the backtick to immedeately concatenate:
Code:sudo rm -r `find / -name rhythm*`
- 08-06-2011 #6
- 08-06-2011 #7Linux Newbie
- Join Date
- Apr 2010
- Location
- Novosibirsk, Russia
- Posts
- 136
Why do not use pipes?...
Code:find <find args> | rm <rm args>
- 08-06-2011 #8Just Joined!
- Join Date
- Jun 2005
- Posts
- 2
That will bypass any "max arguments list" encountered by the backtick method. It will alow allow xargs to work on files found in paths with spaces in them, e.g.Code:find . -type f -name rhythm\* -print0 | xargs -0 rm
/home/user/documents/old stuff/rhythmbox.txt
- 08-06-2011 #9
^Bingo. And if you have the list already in a file
xargs -0 rm < file
- 08-06-2011 #10Linux User
- Join Date
- Jan 2005
- Location
- Saint Paul, MN
- Posts
- 262


6Likes
Reply With Quote
