HP3000-L Archives

June 2005, Week 3

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Peter Smithson <[log in to unmask]>
Reply To:
Peter Smithson <[log in to unmask]>
Date:
Mon, 20 Jun 2005 16:56:11 +0100
Content-Type:
text/plain
Parts/Attachments:
text/plain (93 lines)
Hi,

Just to go on topic for a bit (well MPE related)- what is the MPE intrinsic
to expand wildcards?  I spent a while looking but couldn't see it.

I agree that the xargs sytnax is obscure and tricky. I've not had to use it
for many years - when limits were a lot lower than they are now.(you can
configure HPUX to allow 2Mb of file names now)  But there's a very simple
solution.  Instead of "rm *" -

cd ..
rm -rf <where you were>

Maybe that won't work for other situations/utilities but I'm not sure what
you would do with other OS's when the particular utility (or API imposed
limit) doesn't have enough space.  Just because some API or utility does the
wildcard expansion rather than the CI, it doesn't mean there's necessarily
no limit - it depends how the API works.  (maybe it accepts a static array
of strings to populate?)

The poster who said you can't prompt for removing all files meant the "Are
you sure you want to remove all the files" type prompt that you get from the
Windows DEL command.  This is different to "rm -i" where it asks on every
single file.

Cheers

Peter


>Disadvantages:
>Can't do a "are you sure" type prompt when all files are being
>removed in a directory. Possibly some situation where knowing
>you've got the whole directory could make things quicker.

There is more serious disadvantage.  It is common on HP-UX and
Linux to encounter situations where directories containing very
many files cannot be expanded because the buffer limits of the OS
workspace are exceeded thereby.  When this happens one is forced
into performing the task in arbitrary segments using regexps
constructed so as not to exceed the limit; or else into exotic
command constructs using fairly obscure (for the typical user)
features and options on seldom used utilities like find and xargs.

While the effect of rm * on a very large number of files can be
made to happen using "find -type f -name '<regexp>' -print |xargs
{}" this convenience is purchased only at a considerable cost in
discovering how.

NOTE BENE: Do not use this construct in the posix shell as written.

I am pulling it from memory as an rhetorical example and I have
undoubtedly have forgotten something important in the syntax needed

to make it work.  Besides which, I only do this stuff on Linux and
the MPE posix shell may be significantly different.

With respect to the original example of a disadvantage; in Linux
the default behaviour of rm actually is to ask before deleting each

file.  This can be disabled using rm -f | --force <regexp>

P.S.

obscure rm hints:

to remove a file with the form -anameofafilewithaleadinghyphen use:

(Linux)
rm -- -anameofafilewithaleadinghyphen

(unix)
rm - -anameofafilewithaleadinghyphen

Note the option terminator flags, -- (Linux) and - (Unix), before
the filename argument.

or

(both)
rm ./-anameofafilewithaleadinghyphen

Filenames with a leading "." need to be escaped in regexp
selections thus:

rm ./\.*withleadingdot

Regards,
Jim

* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *

ATOM RSS1 RSS2