How do I delete files w/control char embedded in file name?

How do I delete files w/control char embedded in file name?

Post by Tad McClell » Tue, 13 Jun 1995 04:00:00




This doesn't actually solve the problem, but it may help troubleshooting:

: letters (there are three named BQ, others are BQQBQ, CS, CSSPA,
                     ^^^^^^^^^^^^^^
filenames must be unique within a directory. Since you see three 'BQ's I
too am sure there are unprintable chars in the names.

: I'm sure there are control characters mixed in with the actual
: letters that appear on the screen, but I don't know how to get

I use this to tell if some unprintable chars are in a filename. Doesn't
tell you what unprintable chars, but at least I know they are there.

ls | sed -e 's/^/:/' -e 's/$/:/'

This delimits each filename with colons.

To find out the control chars you could ls >listing_file, and then do
'od' on listing_file.

--

---------------------------------------------------------------------
|
| Tad McClellan,      Logistics Specialist (IETMs and SGML guy)
|                     Lockheed Martin Tactical Aircraft Systems
|                     P.O. Box 748   MZ 1025
|                     Fort Worth, TX 76101
|
|                     voice: (817) 763-6314

|
---------------------------------------------------------------------
|
| Just be thankful we don't get all the government we pay for!
|
---------------------------------------------------------------------

 
 
 

How do I delete files w/control char embedded in file name?

Post by Mats L?fstr » Tue, 13 Jun 1995 04:00:00


: I use this to tell if some unprintable chars are in a filename. Doesn't
: tell you what unprintable chars, but at least I know they are there.

: ls | sed -e 's/^/:/' -e 's/$/:/'

: This delimits each filename with colons.

How about using the capabilities of "ls" instead? Like the "-b" och
the "-q" options? Or maybe even the "-1" option (if you're on a BSD
or SVR4 system) could be of help?

I'm not into RTFM:ing people, but I get a bit tired when people don't
look at the most obvious place for fixing problems. In the case, the
problem is to look at strange file names, and since ls is the command
for looking a file names, why not try to solve the problem with ls?

        mla
--


 
 
 

How do I delete files w/control char embedded in file name?

Post by pet.. » Sat, 17 Jun 1995 04:00:00


The easiest way is to use rm -i *
This will prompt you whether to delete each file individually, so you
can respond y to the offending files. If you are having trouble identifying
which files contain control characters, use the -b or -q options on ls
when listing the directory. -b displays non-printing characters in octal,
and -q prints them as a ?.

Pete

            -----------------------------------------------------