473,320 Members | 1,746 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Sort of OT - perl files

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
Jul 19 '05 #1
2 1690
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.
Jul 19 '05 #2
* Peter Jones <jo*****@optushome.com.au> [2003-08-27 00:43]:
Phil Healey <ps********@hotmail.com> wrote in
news:20*******************@adlerpacific.com:


Thanks! It works great!

--
Phil Healey
Somewhere in cyberspace
Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: John Smith | last post by:
Hello, I have a rather odd question. My company is an all java/oracle shop. We do everything is Java... no matter what it is... parsing of text files, messaging, gui you name it. My question...
5
by: Premshree Pillai | last post by:
Hello, I recently wrote a Perl version of pyAlbum.py -- a Python script to create an image album from a given directory -- plAlbum.pl . It made me realize how easy-to-use Python is. ...
3
by: Brian McGonigle | last post by:
I'm a Perl programmer learning Python (up to chapter 7 in Learning Python, so go easy on me :-) and I find that I look to do things in Python the way I would do them in Perl. In Perl functions and...
3
by: John Smith | last post by:
Hello, I have a rather odd question. My company is an all java/oracle shop. We do everything is Java... no matter what it is... parsing of text files, messaging, gui you name it. My question...
2
by: Wiseguy | last post by:
OK. I need to sort a list and I have the following code @L=(35,10,0,27,100,-4); sub numeric { $A <=> $b; } @L=sort numeric @L; The only reference I have is an ancient Oreilly book on Perl 4....
2
by: shruti | last post by:
hiii all I'm tryin to call a perl script from a C program in following 2 ways- 1.By callin system function. But there's some problem because the system function is not able to executeany...
18
by: xahlee | last post by:
Last year, i've posted a tutorial and commentary about Python and Perl's sort function. (http://xahlee.org/perl-python/sort_list.html) In that article, i discussed a technique known among...
4
by: jonathan184 | last post by:
Hi I have a perl script, basically what it is suppose to do is check a folder with files. Now the files are checked using a timestamp with the command ls -l so the timestamp in this format is...
1
by: megaman1 | last post by:
I’m trying to connect with perl DBD::Oracle on Windows to Oracle DB (Linux). I compiled the Oracle.dll using the commands “perl Makefile.pl” “nmake” and “nmake install”, but when I try to connect...
10
by: happyse27 | last post by:
Hi All, I got this apache errors(see section A1 and A2 below) when I used a html(see section b below) to activate acctman.pl(see section c below). Section D below is part of the configuration...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.