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 file.pl; chmod a+x file.pl; vim file.pl

    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
    [filename]'

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

  2. Phil Healey

    Peter Jones Guest

    Phil Healey <> wrote in
    news::

    >> 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/redhat-list/1998-October/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.
     
    Peter Jones, Aug 27, 2003
    #2
    1. Advertising

  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
    #3
    1. Advertising

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
    Replies:
    0
    Views:
    552
    nobody
    Jun 1, 2004
  2. JerryJ
    Replies:
    11
    Views:
    1,417
    Dave Moore
    Apr 28, 2004
  3. Navin
    Replies:
    1
    Views:
    728
    Ken Schaefer
    Sep 9, 2003
  4. colin_lyse
    Replies:
    1
    Views:
    156
    Tore Aursand
    Feb 3, 2005
  5. Jose Luis

    Perl sort different from unix sort

    Jose Luis, Mar 3, 2011, in forum: Perl Misc
    Replies:
    3
    Views:
    373
    Steve C
    Mar 3, 2011
Loading...

Share This Page