LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 08-17-2009, 10:12 AM   #16
:::
Member
 
Registered: Aug 2009
Distribution: slackware 12.2
Posts: 51

Rep: Reputation: 17

Quote:
Originally Posted by Paraply View Post
"rm -r ./*_files" --> works, but only in the first directory. It looks to me as if "./" is disabling the recursive functionality.

What am I doing wrong?
the ability of the humans mind to associate and to "understand" what others mean is called empathy. it isn't implemented in any computer yet, as far as i know. you have to exactly tell the computer what it should do. they are not good at guessing .

the "-r" option tell rm to remove a directory by recursivly travelling it down and removing each and every file/dir in it up to the top directory.

the command "rm -r ./*_files" does the following:
1. check the directory "./" for entries (inodes) matching the pattern "*_files".
2. if you find one, remove it (recursivly if necessary, i.e. if it's a directory)

it does not mean "travel all the subdirs in "./" recursivly till you find an entry matching the pattern "*_files" and then remove it recursively. your command implies to recursions yet you have told the bash only of one. in other words: if you have a directory ./somedir/dir_files/ the above command will not find the dir "dir_files" because "rm" only searches the directory "./" (note: the "-r" option doesn't mean "search recursivly" but "remove recursivly")

to solve your problem you should use find and xargs:
Code:
find ./ -name '*_files' | xargs rm -r
but try this command first without xargs and check the output to make sure it found all files correctly.

cheers :::

p.s. these live topics kill me. there was one answer when wrote my reply just to find out that meanwhile other recommended the same and a lot easier.

Last edited by :::; 08-17-2009 at 10:16 AM.
 
Old 08-17-2009, 10:14 AM   #17
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
Quote:
Originally Posted by Paraply View Post
somehow I seem to get totally lost whenever I try perusing 'man find'...
With you there! A key concept is that find arguments are a series of tests followed by actions performed if the tests are passed.
 
Old 08-17-2009, 10:44 AM   #18
Paraply
Member
 
Registered: Jun 2007
Location: Norway
Distribution: Arch Linux
Posts: 80

Original Poster
Rep: Reputation: 24
Quote:
Originally Posted by onebuck View Post
Hi,

Glad to hear you got what you want.

Sorry about the mix up.

(...)
Hi Gary,

no problem. Now

Thanks for the links. Actually, I have gigabytes of Linux books and tutorials on my system and after about two years with Linux one should think I'd found the time to learn at least the elementary stuff. Alas, not so. Or I learn a few tricks and then go and forget them... I even have a Slackware derivative, Bluewhite, installed. Apparently it has not helped any... My consolation, or excuse, is that I am spending most of my time with non-technical stuff. Thanks to LinuxQuestions.org, people like me are still partly functional

Last edited by Paraply; 08-17-2009 at 10:46 AM.
 
Old 08-17-2009, 11:02 AM   #19
Paraply
Member
 
Registered: Jun 2007
Location: Norway
Distribution: Arch Linux
Posts: 80

Original Poster
Rep: Reputation: 24
Quote:
Originally Posted by ::: View Post
(...)
p.s. these live topics kill me. there was one answer when wrote my reply just to find out that meanwhile other recommended the same and a lot easier.
Oh, but you gave me another, different gem to save. Thanks! Yes, computers are still seriously lacking in empathy, but I hear they are working on that - what with 'quantum computers', 'AI' and all. However, since nobody seems able to figure out Bell's Theorem, we may still have to wait a while before Haskell can be put to serious use...?

@catkin: Thanks for the tip!
 
Old 08-17-2009, 01:39 PM   #20
onebuck
Moderator
 
Registered: Jan 2005
Location: Midwest USA, Central Illinois
Distribution: SlackwareŽ
Posts: 12,761
Blog Entries: 27

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
Hi,

Like most say 'use it or lose it'.
 
Old 08-17-2009, 11:53 PM   #21
casperdaghost
Member
 
Registered: Aug 2009
Posts: 349

Rep: Reputation: 16
a guy at work created a script with rm and a 'catch all' ..... * to get rid of core files.
something very very bad happened.

be careful with rm
 
Old 08-18-2009, 09:03 AM   #22
onebuck
Moderator
 
Registered: Jan 2005
Location: Midwest USA, Central Illinois
Distribution: SlackwareŽ
Posts: 12,761
Blog Entries: 27

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
Hi,

Whenever testing or experimenting you should never work on a production machine.
 
  


Reply

Tags
delete, recursive, rm


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
"Ending Session" Problem mickeyboa Fedora 2 03-11-2008 09:32 AM
smb.conf having share names ending in "$" the_imax Linux - Server 3 03-11-2008 05:50 AM
shell script to recursively "compare" all files in a directory... silex_88 Programming 3 05-12-2007 04:24 AM
LXer: Displaying "MyComputer", "Trash", "Network Servers" Icons On A GNOME Desktop LXer Syndicated Linux News 0 04-02-2007 08:31 AM
Recursively deleting ".directory" Frank616 Linux - Software 2 03-25-2005 11:58 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:43 AM.

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