Shell wildcard expansion

Tom Christiansen tchrist at convex.COM
Wed Jun 26 02:06:00 AEST 1991


>From the keyboard of suley at xantos.uio.no (Suleyman Kondakci):
:
:Here is a simple csh-script, which renames its *.c args to *.o files:
:
:#! /bin/csh
:if ($#argv) then
:	foreach from ($*)
:		set renew = `echo $from:r`
:		echo moving $from to $renew.o
:		mv $from $renew.o
:	end
:exit 0
:endif
:# Didn't exit safely
:cat <<EOF
:`clear`
:
:Syntax: $0 from_1.c from_2.c  to_1.o to_2.o ...
:EOF


I prefer this one:  :-)

    #!/bin/csh -f
    foreach file ($*) 
	cc -c $file && rm -f $file
    end


Really guys, we can all spin little shellamabobs to do this kind of thing.
The interesting ones are the open-ended ones.  Plus, heh, isn't this a FAQ?

--tom
--
Tom Christiansen		tchrist at convex.com	convex!tchrist
		"So much mail, so little time."  



More information about the Comp.unix.shell mailing list