Hi,
I am writig this script and usually I have prompts like:
echo "Enter file name: "
read "$filename"
So later when I want verify the name to something I can:
if [ "$filename" = "penski" ]
then
echo "Hello $filename"
Anyways how is this done without prompting for example:
I have a script that manages files, but when running the program you type this at the command line:
file mynewfile.txt
where mynewfile is a file in my dir and file is the name of the script:
Becuase I need my script to say whether this is a valid file in my dir.
Thanks,
Arguments to shell scripts take the form $0, $1, $2, etc. where either $0 or $1 (forgot) is the name of the script and the next one is the next argument etc. so:
file hello.txt
$0 (or $1 ... you need to check) is "file"
$1 (or $2 ... you need to check) is "hello.txt"
Those shell variables are outlined in the shell books you own Astudent, if memory serves me tonight.
If I got you correctly , you don't look for the command line argument parsing ($0 is for the command name itself and $1 the first param - checked in "Unix in a Nutshell")
What you look for is maybe testing if a filename exist in the current direcotry ?
To do that you just use on ksh:
if [ ! -e "$1" ];
then
echo this file does not exist
fi
next time please specify which shell you are using sh/ksh/csh...