954,525 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Advantage of using shell(ksh/bash etc) compared to perl?

Hi,

I understand the advantages of using perl over other shell programming techniques like sh,ksh,bash etc. I understand that perl is very powerful and advanced.

But, here, i want to know, if there is any situation, where in, we prefer to use the usual shell programming over perl? Any performance gain? Or any other advantage? I know that Perl can act in many ways that shell scripts cannot, such as in cgi scripts. But as far as acting on the system and its files, or acting only locally, it seems that shell scripts are more powerful?

Thanks
Nisha

Nisha R
Newbie Poster
1 post since May 2006
Reputation Points: 10
Solved Threads: 0
 

There is pretty much no reason to use shell scripting if you're guaranteed that your environment will have perl, unless that's what you happen to prefer. Except for maybe some really small stuff.

Rashakil Fol
Super Senior Demiposter
Team Colleague
2,658 posts since Jun 2005
Reputation Points: 1,135
Solved Threads: 177
 

Ten lines of shell script is easier to maintain than 70 lines of perl.
It's also faster to develop.

Experienced sysadmins use shell scripts, then use perl/ruby/python when they cannot do whatever it is in shell coveniently or very well.

In practice what usually happens is that new sysadmins learn one thing really well and use it for everything. eg, perl or ksh. This practice is usually frowned upon in big companies where creating hard to maintain code is frowned upon. Hard to maintain code is what you often get when you push a facility to the very edge of it's capbilities - usually because you don't any other way to do it.

jim mcnamara
Junior Poster
180 posts since May 2004
Reputation Points: 62
Solved Threads: 10
 

It all depends on what you are trying to do

Sometimes what takes 100 lines in shell to do can be achieved by using a simple perl module !

Sometimes a single bash shell command can do the job for you neatly

so it depends on the usage and user.

chrisranjana
Junior Poster in Training
83 posts since Jul 2005
Reputation Points: 11
Solved Threads: 3
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You