Hey. I'm just getting started with scripting and although i will admit i haven't searched the forum yet, i think it would be a waste of time. It really will be very simple.
I want to enter a list of arguments after my script with the last being the filename. (not the first, as this is part of the requirements)
I so far have
Code:
var=$#
filename=$var
echo "last argument is $filename"
Now i have put every variation i can think of around the second lines var in order the change the value of filename to be from the location in the list of arguments to the argument itself, ie if i put
sh script hi there smelly
smelly is the last argument.
i want the filename to take on the value of the file smelly, not the value 3 (3rd argument)
if i put sh script hi there scriptfile1
where scriptfile1 exists and is the file i want to to point to, it still has argument 3. Whilst I would rather have it point to a file that already exists, i don't mind if it creates a new tempfile, (and will do checks on if files exist once i can get this sorted) i would just like to know how i can have it point to a filename rather than the argument number.
I'm sure i've made that a lot more difficult that it is, but any advice would be appreciated.
Regards, and thanks for your time!
Mitch.