[X-Unix] Files Whose Names Begin With "."

Ken Rossman rossman at columbia.edu
Wed Nov 24 16:03:22 PST 2004


Here's a way to recursively delete selected dot files (adjust the 
patterns
to suit your specific needs);

   $ rm -r .[0-z]*

This will delete any files that start with .0 through any files that
start with .z, going by the ASCII collating sequence.  Obviously, the
above pattern will not do anything to "." or "..".  It also doesn't get
rid of ".#*" files (which can sometimes appear as a byproduct of certain
programs).  But it will get rid of an awful lot of other files.

That being said, you probably DON'T want to execute that command in
your home directory.  Files like your .profile, and a host of .*rc files
will disappear, and you probably want to keep those around.

Be *very* selective and *very* careful with commands like this.

KR

On Nov 24, 2004, at 6:46 PM, Brian Medley wrote:
> On Wed, Nov 24, 2004 at 05:02:00PM -0600, Rod Buchanan wrote:
>> On 11/24/04 9:23 AM, "Craig A. Finseth" <fin at finseth.com> wrote:
>>> Be carefult though: since it doesn't care, you can get into a lot of
>>> trouble.  For example, NEVER DO:
>>>
>>> rm -R .*
>>>
>>> Unless you want everything in your current directory deleted (:-).
>>
>> AND the parent directory!  If you want a test run
>>
>>     ls -l .*
>>
>> and note what it displays.
>
> In general, I believe that's a good practice.  However, on my box in 
> 10.3.6:
>
> $ ls -lFa
> total 0
> drwxr-xr-x   4 dufus  dufus  136 24 Nov 17:44 ./
> drwxr-xr-x  12 dufus  dufus  408 24 Nov 17:44 ../
> -rw-r--r--   1 dufus  dufus    0 24 Nov 17:44 .b
> -rw-r--r--   1 dufus  dufus    0 24 Nov 17:44 a
> $ rm -R .*
> rm: "." and ".." may not be removed



More information about the X-Unix mailing list