Sort of OT - perl files

Discussion in 'Perl' started by Phil Healey, Aug 26, 2003.

  1. Phil Healey

    Phil Healey Guest

    Here goes: I looked all over the place, and I think I'm still too far
    down on the "steep part of the learning curve" to figure this out.

    When writing perl scripts, I touch the filename and then chmod a+x it so
    that it is executable with './'. Then I edit the new file. What I
    normally do is something like this:

    touch; chmod a+x; vim

    What I want to do is add an alias to my .bashrc file so I can enter one
    command to take care of the above.

    alias touchpl [filename] = 'touch [filename]; chmod a+x [filename]; vim

    is what I want to be able to do, but I don't know how to get it to
    incorporate whatever filename I use.

    Any ideas?

    Phil Healey
    Somewhere in cyberspace
    Phil Healey, Aug 26, 2003
    1. Advertisements

  2. Peter Jones

    Peter Jones Guest

    Phil Healey <> wrote in

    >> 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.


    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 :)

    >> 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...

    Peter Jones, Aug 27, 2003
    1. Advertisements

  3. Phil Healey

    Phil Healey Guest

    * Peter Jones <> [2003-08-27 00:43]:
    > Phil Healey <> wrote in
    > news::

    Thanks! It works great!

    Phil Healey
    Somewhere in cyberspace
    Phil Healey, Aug 27, 2003
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. nobody
    Jun 1, 2004
  2. JerryJ
    Dave Moore
    Apr 28, 2004
  3. Navin
    Ken Schaefer
    Sep 9, 2003
  4. colin_lyse
    Tore Aursand
    Feb 3, 2005
  5. Jose Luis

    Perl sort different from unix sort

    Jose Luis, Mar 3, 2011, in forum: Perl Misc
    Steve C
    Mar 3, 2011

Share This Page