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 12-14-2010, 06:37 AM   #16
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 pwc101 View Post
I shy away from the .* wildcard because I've always though it'd expand to '..'. I tend to use .??* which forces the wildcard to expand to at least three characters (thereby omitting '..'). It still catches most dot-files: only those whose file name is fewer than three characters long don't get deleted. I have yet to come across such a file.
Prudent but not necessary because rm will not remove . and .. (kind of like not cutting off the tree branch you are sitting on). Here's a demonstration at the command line:
Code:
c@CW8:/tmp$ mkdir -p dir/dir && cd dir/dir
c@CW8:/tmp/dir/dir$ rm -fr .*
rm: cannot remove directory: `.'
rm: cannot remove directory: `..'
It is to hide these messages that the 2>/dev/null is used.
 
Old 12-14-2010, 07:46 AM   #17
Isix
Member
 
Registered: Mar 2007
Location: Windhoek, Namibia
Distribution: Slackware, Kubuntu, Mandriva & PCLinuxOS
Posts: 80

Original Poster
Rep: Reputation: 18
allright catkin, I incorporated the parentheses. About the position that I entered the line --- I misquoted myself, I actually pasted the line after the line:
Code:
fi # Done checking root filesystem
 
Old 12-14-2010, 08:22 AM   #18
pwc101
Senior Member
 
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847

Rep: Reputation: 128Reputation: 128
Quote:
Originally Posted by catkin View Post
Prudent but not necessary because rm will not remove . and .. (kind of like not cutting off the tree branch you are sitting on). Here's a demonstration at the command line:
Code:
c@CW8:/tmp$ mkdir -p dir/dir && cd dir/dir
c@CW8:/tmp/dir/dir$ rm -fr .*
rm: cannot remove directory: `.'
rm: cannot remove directory: `..'
It is to hide these messages that the 2>/dev/null is used.
Thanks, that's good to know. I'd never really tested it, but the thought occurred to me, so I do this to avoid the possibility. This may also be a GNUism, which means the BSDs (and particularly OS X in my case) may not be so thoughtful.

Another interesting feature I recently found out about GNU rm is that by default it will not remove the root directory:
Quote:
Originally Posted by man rm
--preserve-root
do not remove `/' (default)
 
Old 12-25-2010, 09:02 AM   #19
Richard Cranium
Senior Member
 
Registered: Apr 2009
Location: Carrollton, Texas
Distribution: Slackware64 14.2
Posts: 2,461

Rep: Reputation: 963Reputation: 963Reputation: 963Reputation: 963Reputation: 963Reputation: 963Reputation: 963Reputation: 963
Quote:
Originally Posted by Tinkster View Post
Ummm ... no, you can't, you shouldn't. Many apps, including X11,
have temporary files in /tmp for users CURRENT sessions. Deleting
those can make "bad things" happen. It's safe to delete OLD stuff
from /tmp, things that aren't currently being accessed.
That shouldn't matter.

The inodes allocated to open files aren't put in the free list until all file descriptors for the file are closed.

See http://www.win.tue.nl/~aeb/linux/lk/lk-6.html, where it is stated
Quote:
The filesystem keeps track of the number of names a file has, and the system keeps track of the processes that currently have an open file descriptor for the file. When the last name is removed from the filesystem, and all file descriptors for the file have been closed, the blocks that the file occupied can be put onto the free list.
 
  


Reply


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
ffmpeg.SlackBuild: line 194: cd: /tmp/SBo/package-ffmpeg/usr/man: No such file or dir darkstarbyte Linux - Software 7 12-29-2010 06:45 PM
I carelessly deleted /tmp deco81 Linux - Newbie 2 07-01-2010 10:26 AM
Things one can safely delete from /tmp folder glore2002 Slackware 24 09-17-2009 06:09 PM
deleted contents of /tmp dave`2005 Slackware 2 06-22-2007 11:45 PM
what files can be safely deleted to save disk space? rohan208 Linux - General 9 05-27-2004 09:06 PM


All times are GMT -5. The time now is 02:10 PM.

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