Can anyone direct me to a resource that explains scripting in simple terms?
I have visited many sites and browsed this forum and have yet to find simple explanations.
-
Start with "#!/bin/sh" or whatever shell you want to use.
-
Put whatever commands you want in the script. Which are the same as what you can type at the command line.
-
make it executable with chmod +x
-
"man sh" is the ultimate resource
Which is rather like saying to play the flute you blow at one end and move your fingers over the holes.
#!/bin/sh
# that comment is picked up by exec() and causes this script to be run by /bin/sh
echo this is a script
for d in a b c
do
echo $d
done
I understand a bit more about this after reading your post.
Do you know of any resources that give step by step explanations using visuals?
Some links ...
Shell Scripting Tutorial (Beginner-Intermediate)
Bourne Shell Programming
Advanced Bash-Scripting Guide
BASH Programming - Introduction HOW-TO
Jean-Pierre.
These links look good.
If I have any further questions can I refer them to you?
Okay, so I have a small script ( my first ) and want to know what the proper formatting is ? Should the .txt file be saved in the bin folder?
How does it become an executable?
it is traditionally either
(a) a file with no extension, eg "foo"
(b) a file with .sh as the extension, such as "foo.sh"
(c) a file with the type of shell as the extension, eg "foo.ksh"
It can live anywhere or on the PATH. You can say ./foo.sh or myfoo/foo.sh etc.
To make it executeable use "chmod +x foo.sh" to change the executable rights.
on cygwin; trying to create a script for a red hat linux environment.
can I type the script in notepad ?
I suggest you get a working knowledge of "vi". It will save you in the long run.