Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Sort of OT - perl files

Reply
Thread Tools

Sort of OT - perl files

 
 
Phil Healey
Guest
Posts: n/a
 
      08-26-2003
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
 
Reply With Quote
 
 
 
 
Peter Jones
Guest
Posts: n/a
 
      08-27-2003
Phil Healey <(E-Mail Removed)> wrote in
news:(E-Mail Removed):

>> 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.
 
Reply With Quote
 
 
 
 
Phil Healey
Guest
Posts: n/a
 
      08-27-2003
* Peter Jones <(E-Mail Removed)> [2003-08-27 00:43]:
> Phil Healey <(E-Mail Removed)> wrote in
> news:(E-Mail Removed):
>


Thanks! It works great!

--
Phil Healey
Somewhere in cyberspace
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
FAQ 5.38 Why does Perl let me delete read-only files? Why does "-i" clobber protected files? Isn't this a bug in Perl? PerlFAQ Server Perl Misc 0 03-09-2011 11:00 PM
Perl sort different from unix sort Jose Luis Perl Misc 3 03-03-2011 09:14 PM
FAQ 5.38 Why does Perl let me delete read-only files? Why does "-i" clobber protected files? Isn't this a bug in Perl? PerlFAQ Server Perl Misc 0 02-11-2011 05:00 AM
can Perl Sort do this, unix sort breaks on it (muliple spaces as demiliter) colin_lyse Perl Misc 1 02-03-2005 01:13 AM
Ado sort error-Ado Sort -Relate, Compute By, or Sort operations cannot be done on column(s) whose key length is unknown or exceeds 10 KB. Navin ASP General 1 09-09-2003 07:16 AM



Advertisments