Simplest way to delete files with unprintable characters?

Simplest way to delete files with unprintable characters?

Post by Christopher Benson-Manic » Wed, 19 Feb 2003 07:51:28



Recently, a student in an introductory CS class ran into a problem with a file
named .^? (the ^? being the control character for backspace or something).  I
suggested a solution, but I fear it may have instilled fear and dread:

rm "$(ls -a | grep ^[.][^a-zA-Z0-9."

Is there a less hackerish way to accomplish this?  (I like the hacker way just
fine myself...)

--
Christopher Benson-Manica      | You have a right to think for yourself.
CS 1321 TA                     | You are controlled because you want to be.
                               | Take a stand on *something*
www.adbusters.org/home         | Why stand on a silent platform?
www.stayfreemagazine.org       | Smash the State, Fight Back.

 
 
 

Simplest way to delete files with unprintable characters?

Post by Christopher Benson-Manic » Wed, 19 Feb 2003 07:52:13


Recently, a student in an introductory CS class ran into a problem with a file
named .^? (the ^? being the control character for backspace or something).  I
suggested a solution, but I fear it may have instilled fear and dread:

rm "$(ls -a | grep ^[.][^a-zA-Z0-9.]"

Is there a less hackerish way to accomplish this?  (I like the hacker way just
fine myself...)

--
Christopher Benson-Manica      | You have a right to think for yourself.
CS 1321 TA                     | You are controlled because you want to be.
                               | Take a stand on *something*
www.adbusters.org/home         | Why stand on a silent platform?
www.stayfreemagazine.org       | Smash the State, Fight Back.

 
 
 

Simplest way to delete files with unprintable characters?

Post by Martin Dickop » Wed, 19 Feb 2003 09:59:58



> Recently, a student in an introductory CS class ran into a problem with a file
> named .^? (the ^? being the control character for backspace or something).  I
> suggested a solution, but I fear it may have instilled fear and dread:

> rm "$(ls -a | grep ^[.][^a-zA-Z0-9.]"

What if other filenames also match the regular expression?

Quote:> Is there a less hackerish way to accomplish this?  (I like the hacker way just
> fine myself...)

I'd just specify the name of the file on the command line. The special
character would need to be quoted with a backslash.

Here, Ctrl+V causes the terminal driver to treat the next entered character
literally, but this may be system specific and/or configurable. Therefore,
I'd try the following key sequence:

  [r] [m] [space] [.] [\] [Ctrl]+[v] [backspace] [enter]

Martin

 
 
 

Simplest way to delete files with unprintable characters?

Post by Christopher Benson-Manic » Wed, 19 Feb 2003 11:32:15


Martin*opp$ cat /dev/random

Quote:> What if other filenames also match the regular expression?

Well, this is a beginning CS student - they have maybe 5 dotfiles, none of
which match that regex...

Quote:> Here, Ctrl+V causes the terminal driver to treat the next entered character
> literally, but this may be system specific and/or configurable. Therefore,
> I'd try the following key sequence:

>   [r] [m] [space] [.] [\] [Ctrl]+[v] [backspace] [enter]

Oh!!  Many thanks :D

--
Christopher Benson-Manica      | You have a right to think for yourself.
CS 1321 TA                     | You are controlled because you want to be.
                               | Take a stand on *something*
www.adbusters.org/home         | Why stand on a silent platform?
www.stayfreemagazine.org       | Smash the State, Fight Back.

 
 
 

Simplest way to delete files with unprintable characters?

Post by those who know me have no need of my nam » Wed, 19 Feb 2003 18:20:28


in comp.unix.programmer i read:

Quote:>Recently, a student in an introductory CS class ran into a problem with a file
>named .^? (the ^? being the control character for backspace or something).  I
>suggested a solution, but I fear it may have instilled fear and dread:

>rm "$(ls -a | grep ^[.][^a-zA-Z0-9."

i don't see any programming here.  in most programming languages those
funny characters shouldn't be an issue.

from a shell perspective there's no need for the command substitution nor
the ls, just ``rm .^?'' where to get the ^? you may need to use the `lnext'
(literal next) prefix character, often ^V.

--
bringing you boring signatures for 17 years

 
 
 

Simplest way to delete files with unprintable characters?

Post by Chuck Dillo » Thu, 20 Feb 2003 00:30:42



> Recently, a student in an introductory CS class ran into a problem with a file
> named .^? (the ^? being the control character for backspace or something).  I
> suggested a solution, but I fear it may have instilled fear and dread:

> rm "$(ls -a | grep ^[.][^a-zA-Z0-9.]"

> Is there a less hackerish way to accomplish this?  (I like the hacker way just
> fine myself...)

In addition to suggestions already made, a simple way to do this is to
use rm's -i switch so that you get prompted for each file.  Then you
can use a glob to match the file and interactively select the right one
to delete.

-- ced

--
Chuck Dillon
Senior Software Engineer
NimbleGen Systems Inc.

 
 
 

Simplest way to delete files with unprintable characters?

Post by Bill Marcu » Thu, 20 Feb 2003 01:56:21


On Mon, 17 Feb 2003 22:52:13 +0000 (UTC), Christopher Benson-Manica

> Recently, a student in an introductory CS class ran into a problem with a file
> named .^? (the ^? being the control character for backspace or something).  I
> suggested a solution, but I fear it may have instilled fear and dread:

> rm "$(ls -a | grep ^[.][^a-zA-Z0-9.]"

> Is there a less hackerish way to accomplish this?  (I like the hacker way just
> fine myself...)

rm -i .*
or mc if it is installed.
 
 
 

Simplest way to delete files with unprintable characters?

Post by Uwe Behl » Thu, 20 Feb 2003 05:39:29



>On Mon, 17 Feb 2003 22:52:13 +0000 (UTC), Christopher Benson-Manica

>> Recently, a student in an introductory CS class ran into a problem with a
>>file
>> named .^? (the ^? being the control character for backspace or something).  I
>> suggested a solution, but I fear it may have instilled fear and dread:

>> rm "$(ls -a | grep ^[.][^a-zA-Z0-9.]"

>> Is there a less hackerish way to accomplish this?  (I like the hacker way
>>just
>> fine myself...)

>rm -i .*
>or mc if it is installed.

Or do an

ls -i

and use the resulting inode in

find -inum xxx -exec rm {} \;

sapere aude,

Uwe Behle

--
Uwe Behle
If mail bounces (spam protection), replace user by alias2..., alias3...
http://df3du.mine.nu

 
 
 

Simplest way to delete files with unprintable characters?

Post by Eric Sosma » Thu, 20 Feb 2003 06:53:40



> In addition to suggestions already made, a simple way to do this is to
> use rm's -i switch so that you get prompted for each file.  Then you
> can use a glob to match the file and interactively select the right one
> to delete.

    The first time I heard of this technique, it was in
a Tale of Woe.  You can reproduce the T.o.W. yourself
by doing something like

        cd directory_with_many_valuable_files
        touch ./-f
        echo Answer y for -f, n for everything else:
        rm -i *

(Kids, DON'T try this at home.  In at least some versions
of "rm", the -f switch effectively overrides -i -- and
now you can guess where the W. entered the T.o.W. ...)

--

 
 
 

Simplest way to delete files with unprintable characters?

Post by Chuck Dillo » Fri, 21 Feb 2003 00:08:05




>>In addition to suggestions already made, a simple way to do this is to
>>use rm's -i switch so that you get prompted for each file.  Then you
>>can use a glob to match the file and interactively select the right one
>>to delete.

>     The first time I heard of this technique, it was in
> a Tale of Woe.  You can reproduce the T.o.W. yourself
> by doing something like

>    cd directory_with_many_valuable_files
>    touch ./-f
>    echo Answer y for -f, n for everything else:
>    rm -i *

> (Kids, DON'T try this at home.  In at least some versions
> of "rm", the -f switch effectively overrides -i -- and
> now you can guess where the W. entered the T.o.W. ...)

Good point.  I was trying to suggest using a more specific glob than *
but that didn't come accross.  'rm -i -- <glob>' is the safe way to go.

-- ced

--
Chuck Dillon
Senior Software Engineer
NimbleGen Systems Inc.

 
 
 

Simplest way to delete files with unprintable characters?

Post by Stephane CHAZELA » Fri, 21 Feb 2003 01:32:45


On Wed, 19 Feb 2003 09:08:05 -0600, Chuck Dillon
[...]

Quote:>> (Kids, DON'T try this at home.  In at least some versions
>> of "rm", the -f switch effectively overrides -i -- and
>> now you can guess where the W. entered the T.o.W. ...)

That's what POSIX requires

Quote:> Good point.  I was trying to suggest using a more specific glob than *
> but that didn't come accross.  'rm -i -- <glob>' is the safe way to go.

Or rm -i ./*

But why not reading the FAQ.

--
Stphane

 
 
 

Simplest way to delete files with unprintable characters?

Post by Chuck Dillo » Fri, 21 Feb 2003 04:10:46



> Or rm -i ./*

> But why not reading the FAQ.

To which FAQ do you refer?  In the UNIX FAQ at faqs.org the answer
(2.2) is basically what I suggested, and it doesn't mention the gotcha
that Eric pointed out BTW.

If you're suggesting that I should have just referred the OP to the
FAQ, point taken.

-- ced

--
Chuck Dillon
Senior Software Engineer
NimbleGen Systems Inc.

 
 
 

1. Script to write unprintable characters to a file

Hey guys,

Is there a command in unix to print
character like ESC, or TAB or ALT
as an ascii character to file? I need
to write a sequecence like this to
a file" ESC E &^*"  but I don't know
how to write the ESC keyboard character.

Thanks

-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----

2. telnet vs rlogin?

3. neat ways of deleting empty lines from a file???

4. Linux Truoubles

5. Deleting many files at once with wilcard characters in the file names

6. ISDN CAUSE E0001B

7. Seaching for unprintable characters

8. Duel Booting

9. unprintable characters

10. How to define unprintable character in flex

11. Delete the extra character from a line in the file

12. Deleting a file whose name is consists of control characters