From owner-freebsd-questions@FreeBSD.ORG Fri Sep 12 06:17:40 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 528771065684 for ; Fri, 12 Sep 2008 06:17:40 +0000 (UTC) (envelope-from ws@au.dyndns.ws) Received: from ipmail05.adl2.internode.on.net (ipmail05.adl2.internode.on.net [203.16.214.145]) by mx1.freebsd.org (Postfix) with ESMTP id C5EEA8FC1F for ; Fri, 12 Sep 2008 06:17:39 +0000 (UTC) (envelope-from ws@au.dyndns.ws) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvoAAHimyUiWZWdv/2dsb2JhbAAItj6BYg X-IronPort-AV: E=Sophos;i="4.32,386,1217773800"; d="scan'208";a="204239905" Received: from ppp103-111.static.internode.on.net (HELO [192.168.1.157]) ([150.101.103.111]) by ipmail05.adl2.internode.on.net with ESMTP; 12 Sep 2008 15:47:37 +0930 From: Wayne Sierke To: DAve In-Reply-To: <48BF71F9.9000004@pixelhammer.com> References: <20080904034833.GA25655@k7.mavetju> <48BF71F9.9000004@pixelhammer.com> Content-Type: text/plain; charset=UTF-8 Date: Fri, 12 Sep 2008 15:47:36 +0930 Message-Id: <1221200256.2581.93.camel@predator-ii.buffyverse> Mime-Version: 1.0 X-Mailer: Evolution 2.22.2 FreeBSD GNOME Team Port Content-Transfer-Encoding: 8bit Cc: freebsd-questions@freebsd.org Subject: Re: cd and rm a directory with '^M' X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Sep 2008 06:17:40 -0000 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 # 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. Of course, the old adage always applies - "If in doubt - print it out!" (Not very catchy, is it?) Wayne