Phil Healey <ps********@hotmail.com> wrote in
news:20*******************@adlerpacific.com:
Make yourself a $HOME/bin directory (if you don't
already have one) and add it to your PATH, and put something all your
useful little utilities there. Then the script itself is just:
A couple of questions:
#!/bin/sh
Should this be #!/bin/bash ?
No. Yes. Maybe. There is a good chance (on most Linux systems) that
/bin/sh is simply a link to /bin/bash, with the caveat that bash will
attempt to mimic the operation of the original Bourne shell when called
as 'sh'. However, when searching google to clarify my own reasons for
using /bin/sh rather than /bin/bash I found the following:
: It doesn't. This is straight Bourne shell. You really should change
: that
: #!/bin/bash
: into
: #!/bin/sh
: You should _never_ place such a dependency on a particular shell
: dialect into a script unless you really really _need_ some oddball
: extension. Write portable scripts and you'll have less trouble in the
: long run, as will others trying to use your scripts.
(
https://www.redhat.com/archives/redh.../msg00584.html)
which essentially confirms what I had been led to believe. Unless you
have a script which specifically requires bash, it is generally best to
use "#!/bin/sh" as meaning "the generic system shell". All of which is
getting rather OT, and I'd recommend further questioning of this point
be directed to comp.unix.shell :-)
touch $1
chmod a+x $1
vim $1
And just to get this straight: I write the script and save it as
'touchpl' (or whatever) and from then on I just type 'touchpl [file]'
at the shell prompt and voila?
Indeed. The '$1' in a shell script represents the first argument -- in
this case, '[file]'...
Apologies to all for the off-topic spiel...
Pete.