copying files

Chris Torek chris at mimsy.umd.edu
Fri Dec 7 03:53:38 AEST 1990


>In article <1990Dec5.021951.28104 at en.ecn.purdue.edu>
 nichols at en.ecn.purdue.edu (Scott P Nichols) asks how to match `.*' without
 matching . and .. (in essence, anyway).

In various articles various people give incorrect and/or incomplete answers.
One of the best answers is:

In article <EMV.90Dec5104011 at crane.aa.ox.com> emv at ox.com (Ed Vielmetti) writes:
>I usually use .??*, which works unless you have a file like ".a" or
>".Z". 

This is correct.  `.??*' matches all files where:
	- the name begins with `.', and
	- the name contains at least three characters
Since there is only one file that has one character and begins with `.',
namely `.', all that is left are the two-character files whose name begins
with `.'.  You want all but `..'.  If any such files exist, the pattern

	.[^A--/-^?]

will match them.  Note: ^A here represents a literal control-A, and
^? represents either a literal DEL (if you have only 7-bit shells and
files) or meta-DEL (if you have 8-bit shells and files).

Since it is generally not desirable to pass the pattern on if no files
match (as is normal under sh and occurs when you `set nonomatch' in
csh), you should use

	.[^A--/-^?] .??*

only if you do have two-character-name `.' files.

Alternative solutions using `ls -A' or `ls -a' and/or sed and so forth
are available.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris at cs.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.unix.shell mailing list