[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: shell scripts

>Hello, RHL;
>	Here's an interesting one for you:
>I wrote this script (it's really not important what it does but here it is
>so you can follow me):
>	#!/usr/bin/env bash
>	if [ -d ./archive0 ]
>	then
>        	mv -i $1 ./archive0
>	elif [ -f ./archive0 ]
>	then
>        	echo "File archive0 exists.
>	Delete and try again or don't use this command."
>	else
>        	mkdir ./archive0
>        	mv -i $1 ./archive0
>	fi
>It's called archive0.

I have to assume that the script, named archive0, does NOT exist in the
same place where the directory archive0 exists, since it physically couldn't.

>When I send it a wildcard, say
>archive0 tournaments.*
>It only grabs the first file (alphabetically), i.e., if my pwd contains
>the files
>	tournaments.aux  tournaments.log  tournaments.tex
>	tournaments.dvi  tournaments.ps
>the script only grabs tournaments.aux. Hmm...
>	-Jason

Correct, since the 5 files will be assigned to $1 through $5.  You are
only looking at $1.  You need to use $*.  If you were to test each of the
files for some reason, then a for loop would be needed.

e-mail: vidiot vidiot com
    Bart: Hey, why is it destroying other toys?  Lisa: They must have
    programmed it to eliminate the competition.  Bart: You mean like
    Microsoft?  Lisa: Exactly.  [The Simpsons - 12/18/99]
Visit - URL:http://www.vidiot.com/  (Your link to Star Trek and UPN)

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]