UNIX command line arguments

Dave Turner dmt at PacBell.COM
Tue Jun 12 09:00:52 AEST 1990


In article <319 at iczer-1.UUCP> emm at iczer-1.UUCP (Edward M. Markowski) writes:
:In article <352 at ankh.ftl.fl.us> chin at ankh.ftl.fl.us (Albert Chin) writes:
:>the case of "mv file.* myfile.*". Would **argv then contain "mv file.1
:>myfile.1 file.2 myfile.2 file.3 myfile.3". If so, then I understand, but
:>if now, then how else does it work.
:You have it right except for one point. When the shell expands the * or []
:or whatever else you put on the line it alphabitizes(sp?) them.
:You have to rember that some commands need the parameters in a specific
:order. mv will work with many parameters as long as the last one it the
:name of a directory.

The bourne and korn shells sort each expansion individually which retains
the position of those arguments which defy expansion.

The man(1) page for [b]sh(1) in my System V R2.1 manual states about
File Name Generation:

.... The *word* is replaced with alphabetically sorted file names that
match the pattern. If no file name is found that matches the pattern,
the word is left unchanged.

The command:

	echo [e-j]* . [a-d]* .

produced the expected, desired results: all file names beginning with
letters e through j, a dot, all file names beginning with letters a
through d, and a final dot.


-- 
Dave Turner	415/823-2001	{att,bellcore,sun,ames,decwrl}!pacbell!dmt



More information about the Comp.lang.c mailing list