Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 12 Sep 2008 17:23:39 -0400
From:      DAve <dave.list@pixelhammer.com>
To:        freebsd-questions@freebsd.org
Subject:   Re: cd and rm a directory with '^M'
Message-ID:  <48CADDDB.1070308@pixelhammer.com>
In-Reply-To: <1221200256.2581.93.camel@predator-ii.buffyverse>
References:  <20080904034833.GA25655@k7.mavetju>	<48BF71F9.9000004@pixelhammer.com> <1221200256.2581.93.camel@predator-ii.buffyverse>

next in thread | previous in thread | raw e-mail | index | archive | help
Wayne Sierke wrote:
> On Thu, 2008-09-04 at 01:28 -0400, DAve wrote:
>> Edwin Groothuis wrote:
>>>> I had rsync create a directory with a '^M' in it.
>>> Use command-line completion:
>>>
>>> [~/xx] edwin@k7>touch foo^Mbar		# that's ^V^M
>>> [~/xx] edwin@k7>ls -l
>>> total 0
>>> -rw-r--r--  1 edwin  edwin  0 Sep  4 13:46 foo?bar
>>> [~/xx] edwin@k7>rm foo <TAB>		# autocompletes to foo^Mbar
>>>
>>>
>> If you find yourself on a machine without a full featured shell you can 
>> delete by the inode number. Chuck Swiger saved my bacon with that trick 
>> several years ago.
>>
>> [sysadmin /usr/home/sysadmin]$ touch abc^M
>> [sysadmin /usr/home/sysadmin]$ ls -i
>> 2449500 abc?   2449511 env.sh
>> [sysadmin /usr/home/sysadmin]$ find . -type f -inum 2449500 | xargs rm
>> [sysadmin /usr/home/sysadmin]$ ls -i
>> 2449511 env.sh
>>
> However, note that using find's -x option could avoid subsequent
> consternation, embarrassment, or worse. -x avoids having find search
> over multiple filesystems which in this case avoids having find stumble
> upon files with the same inode num on different filesystems. Relevant to
> any type of find criteria, but -inum introduces a nice degree of
> (user-level) randomness to the mix.

Good point to remember.

> 
> Of course, the old adage always applies - "If in doubt - print it
> out!" (Not very catchy, is it?)

I *always* look at what I am going to remove, *before* I remove it. A 
lesson learned the hard way once, learned forever the second time.

DAve


-- 
Don't tell me I'm driving the cart!



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?48CADDDB.1070308>