Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 08-16-2005, 08:44 PM   #1
LQ Newbie
Registered: Aug 2005
Posts: 5

Rep: Reputation: 0
Angry Command Line Help: Remove a List of Files

I'm trying to remove a series of PDF files that reside in many subdirectories. The following commands don't work:

rm -f | find . -name *.pdf 

rm -f < find . -name *.pdf 

find . -name *.pdf > pdf.files.txt 
rm -f < cat pdf.files.txt 

find . -name *.pdf -exec "rm -f {}"
I'm going crazy. Someone please help.
Old 08-16-2005, 08:52 PM   #2
Registered: Apr 2004
Location: Europe
Distribution: Debian, Slackware
Posts: 505

Rep: Reputation: 46
find -name *.pdf -exec rm -f {} \;

Last edited by alienDog; 08-16-2005 at 08:54 PM.
Old 08-17-2005, 04:21 AM   #3
Senior Member
Registered: Jul 2004
Location: Denmark
Distribution: Ubuntu, Debian
Posts: 1,524

Rep: Reputation: 47
$ find -name *.pdf | xargs rm -f
$ rm -f $(find -name *.pdf)
$ for i in $(find -name *.pdf); do rm -f $i; done
You may want to try and cat the files instead of rm'ing them, just in case--spaces and other weird characters in the filenames may not be handled gracefully by my examples (they should be irrelevant in alienDog's code); try setting IFS to '\n'.

Try playing around with the various mechanisms and programs I mentioned; rtm and backup vital data before doing anything stupid

hth --Jonas


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a single command to list all hardware installed (command line)? davee Linux - Hardware 6 02-28-2009 07:19 PM
How to get list of system users from command line? tictocdoc Linux - General 3 03-12-2004 03:06 PM
remove folder from command line demmylls Linux - General 3 02-15-2004 09:52 AM
How may I list only the directories in command line? geraldomanaus Linux - Newbie 5 03-20-2003 12:40 PM
Command to list line length of multiple scripts Tekime Linux - General 2 09-06-2002 01:04 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:49 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration