Shell Scripts

Luke Davis ldavis at shellworld.net
Sat Nov 8 15:14:38 EST 2003


Okay, from start to middle:

A script is just a text file.
It can have any name.  Remember, in Unix, extensions don't matter.

You must make it executable, with:

chmod 700 filename

(After creation)

In the file, the first line should be something like:

#!/bin/bash

(Pound, bang, "/bin/bash")

Now, to answer your question: all variables are handled with dollar signs,
whereas in DOS they were percent signs.

So let's say you wanted a script that would delete the first file and the
second one, and then run nano on the second.

#!/bin/bash

# Deleting the files
echo -n "deleting $1... "
rm $1
echo "done."
echo -n "Deleting the second file ($2)..."
rm $2
echo "done."

nano $2

# Finished.
exit 0

Note, that the "exit 0" is not necessary.  It is just a way to end a
script early, and if you learn more about scripting later, you will find
more creative uses for it.

You may find it useful to read the bash manual page, several times, and
make notes.

Luke






On Sat, 8 Nov 2003, Rejean Proulx wrote:

> I have a bunch of MYSQL tables and files to back up.  I want to write some
> scripts that call functions so that I can reuse them.  I need to have a
> script that gets called like this
>
> backsql tablename weekly
>
> Table name and weekly are 2 parameters.  In dos we use to code that with %1
> %2 or maybe it was just numbers.  How do I pass parameters to a script?  I
> need a sample to work from so I can get started.  Then I can read manuals.
> What file names do I use in Linux.  Would it be backmysql.sh or something
> like that?
>
>  Rejean Proulx
> Visit my family at http://interfree.ca
> MSN is: rejp at rogers.com
> Ham License VA3REJ
>
>
> _______________________________________________
> Speakup mailing list
> Speakup at braille.uwo.ca
> http://speech.braille.uwo.ca/mailman/listinfo/speakup
>




More information about the Speakup mailing list