Hint on removing strange files

William Roberts liam at cs.qmw.ac.uk
Tue Jul 24 19:05:04 AEST 1990


Lots of Mac programs produce exotic filenames containing things
like trademark symbols, those curly Fs that people use to
denote folders and so on. A recent case in point is the INIT
that Disinfectant 2.0 installs in your System Folder, which is
called "X Disinfectant INIT" where X is a diamond character (\327)

The A/UX shells are not 8-bit clean, so they strip off the top
bit, hence

        echo *Disinf*
gives   W Disinfectant INIT

So how do you remove the file that is causing your Mac session
to crash when it loads in this init?

Answer, find a way of passing the filename to rm without having
the shell process it first. The method I came up with is

        find . -name "*Disinf*" -exec rm -i - {} \;

Translated into English this is

find    search for things
.       in the current directory and its subdirectories
-name   whose name matches the pattern
"*Disinf*"      pattern (in quotes so that the shell leaves it alone)
-exec   for any matching file, execute the command
rm      rm
-i      interactive (i.e. prompts for yes/no with each file)
-       all following arguments to rm are filenames
{}      the name of the matching file
\;      that's all (the \ prevents the shell from stealing the ;)

The important bit is that {} is passed from find directly to
the rm command without going through the annoying "strip the
parity bit" that csh insists on. Csh and tcsh fans can probably
make an alias which does this, and sh lovers will naturally
write a shell function for it.
-- 

William Roberts                 ARPA: liam at cs.qmw.ac.uk
Queen Mary & Westfield College  UUCP: liam at qmw-cs.UUCP
Mile End Road                   AppleLink: UK0087
LONDON, E1 4NS, UK              Tel:  071-975 5250 (Fax: 081-980 6533)



More information about the Comp.unix.aux mailing list