You are not logged in.

#1 2010-05-20 04:15:58

jamesob
Member
Registered: 2010-05-17
Posts: 3

Bash still worth learning?

Today I needed to write a script that would copy a few of my dot files into a git repository. I cracked vim open and began to experiment with rudimentary bash constructs, but after a while gave up and decided to write the thing in Python, just because Python is simple and I know it.

Are there any good reasons as to why I should pursue a knowledge of bash with other, higher level languages around (e.g. Python) when bash's breadth of use is (relatively) limited?

Offline

#2 2010-05-20 05:10:53

Cyrusm
Member
From: Bozeman, MT
Registered: 2007-11-15
Posts: 1,053

Re: Bash still worth learning?

I say if you're comfortable with python, and it does what you need it to do, then use python. There is no real "need" to learn Bash imo.  personally I like bash for quick and dirty scripts, python for more elaborate scripts. but really it's just what ever you're happy using.


Hofstadter's Law:
           It always takes longer than you expect, even when you take into account Hofstadter's Law.

Offline

#3 2010-05-20 05:35:43

austin.rbn
Member
Registered: 2010-01-23
Posts: 77

Re: Bash still worth learning?

I also find I am faster with bash for writing very simple scripts. If you plan on distributing scripts, I can imagine that some people would prefer bash versions. However, you certainly know better than anyone else whether python is fulfilling your needs in the best way. Python is using the shell for things like the "pipes" module, anyway.

A knowledge of bash is still useful, obviously, if you might be interested in editing bash scripts which other people have written, or want to distribute scripts where bash is expected. PKGBUILDs spring to mind.


"Computer Science is embarrassed by the computer." -- Alan J. Perlis

Offline

#4 2010-05-20 06:17:03

mikesd
Member
From: Australia
Registered: 2008-02-01
Posts: 788
Website

Re: Bash still worth learning?

Cyrusm wrote:

I say if you're comfortable with python, and it does what you need it to do, then use python. There is no real "need" to learn Bash imo.  personally I like bash for quick and dirty scripts, python for more elaborate scripts. but really it's just what ever you're happy using.

Same here. I made an effort to do more with BASH this year and have written a few things in it. It is great for simple wrappers and adding functionality to your shell. I will sometimes use BASH for bootstrap style scripts as BASH is pretty much standard on most distros. It is in [core] whereas Python is in [extra]. This is probably less of an issue these days. All of my systems have Python installed. I still use Python for the heavy lifting as I know it can do just about anything.

Offline

#5 2010-05-20 06:49:36

Xyne
Forum Fellow
Registered: 2008-08-03
Posts: 6,965
Website

Re: Bash still worth learning?

Every Linux user should have a basic working knowledge of Bash for system scripting. Aliases and .bashrc functions can save a lot of typing, and simple tasks such as managing files and other basic command-line work are very quick and easy with Bash.  It's really practical that you can script anything that you can do from a terminal. I wouldn't use it for anything big though and I often find myself switching between Bash and Perl for system scripting, depending on the intended scope and specific needs. I never use Python for system scripting unless I need a particular module.



trivial system task
crumbs.jpg


Bash
g161-large.jpg


Python
137537_300.jpg


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#6 2010-05-20 07:05:48

Kiwi
Member
Registered: 2008-02-24
Posts: 153

Re: Bash still worth learning?

So what Xyne is saying is that Python sucks more than Bash? Unless, I suppose, if that is a vacuum made by Microsoft.


(There is a quote somewhere something like, "The day Microsoft makes a product that doesn't suck is the day they start selling vacuums," if you did not get it)

Offline

#7 2010-05-20 08:01:49

Runiq
Member
From: Germany
Registered: 2008-10-29
Posts: 1,053

Re: Bash still worth learning?

Kiwi wrote:

So what Xyne is saying is that Python sucks more than Bash? Unless, I suppose, if that is a vacuum made by Microsoft.


(There is a quote somewhere something like, "The day Microsoft makes a product that doesn't suck is the day they start selling vacuums," if you did not get it)

Yeah, that's in moljac's sig if I'm not mistaken.

On topic: If you can do what you want in python, by all means, use python. I'd consider being able to read the occasional bash script is enough, as long as you have something better/more versatile that you can rely on (python, in your case).

Also: Nice one, Xyne. big_smile

Offline

#8 2010-05-20 08:27:10

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,237
Website

Re: Bash still worth learning?

Kiwi wrote:

So what Xyne is saying is that Python sucks more than Bash? Unless, I suppose, if that is a vacuum made by Microsoft.

Heh. Oh the flame wars! tongue

Cyrusm wrote:

I say if you're comfortable with python, and it does what you need it to do, then use python. There is no real "need" to learn Bash imo.  personally I like bash for quick and dirty scripts, python for more elaborate scripts. but really it's just what ever you're happy using.

Exactly my thoughts... If you can achieve the same thing 2 different ways and the result is the same, then do whatever is more comfortable/easier for you.

Although, if you'll excuse this little anecdote..... I used to *hate* perl, with a passion. I'd go out of my way to avoid it, because I didn't know it and when I tried to use it I found it esoteric and painful. Over the last few months though I had managed to get a (basic) grasp of perl, and now I love it. It can make things so much easier than doing the same in bash. The reverse is also true.

Moral of my anecdote (I think): Right Tool for the Right Job. The more tools you have (know), the easier to find a suitable tool for your task.

Offline

#9 2010-05-20 09:17:31

Xyne
Forum Fellow
Registered: 2008-08-03
Posts: 6,965
Website

Re: Bash still worth learning?

Kiwi wrote:

So what Xyne is saying is that Python sucks more than Bash? Unless, I suppose, if that is a vacuum made by Microsoft.

lol

*no comment*




fukawi2 wrote:

Moral of my anecdote (I think): Right Tool for the Right Job. The more tools you have (know), the easier to find a suitable tool for your task.

indeed


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#10 2010-05-20 09:57:16

geniuz
Member
Registered: 2010-04-10
Posts: 127

Re: Bash still worth learning?

Personally, I'm still in the process of learning bash, and if you ask me...it is well worth it. I found a lot of really useful ways to automate daily tasks from editing mp3 tags to making full system back-ups with just one short script. Not only this, but I've also learned to customize the bash environment using .bash_profile and .bash_rc which also makes life considerably easier. So if you ask me, bash is definitally worth while learning, specially if you really go into the details, there won't be a single general task you can't do in the blink of an eye.

I can, however, also imagine that if you know either Perl or Python already, learning Bash might seem redundant. This is much dependent on the task at hand I believe, but for my purposes Bash is more than enough and therefore I have no considerable knowledge in Perl or Python.

Offline

#11 2010-05-20 12:20:09

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: Bash still worth learning?

Did anyone compare the speed of executing scripts bash v. dash? Dash uses less RAM so if you have 20 instances open on a 512 MB machine it may make a difference.

Offline

#12 2010-05-20 15:57:03

MercuryShadow
Member
From: Chciago 'burbs
Registered: 2010-01-04
Posts: 29

Re: Bash still worth learning?

I generally prefer perl to bash, but when the task at hand calls for running a number of shell commands, I find bash is the way to go.

Like others have said, bash is worth knowing for a number of reasons. Like others, I have used .bashrc to fine-tune my shell and the results have been great. Heck, it's worth knowing for that reason alone.

Last edited by MercuryShadow (2010-05-20 15:57:16)

Offline

#13 2010-05-20 16:02:19

.:B:.
Forum Fellow
Registered: 2006-11-26
Posts: 5,819
Website

Re: Bash still worth learning?

karol wrote:

Did anyone compare the speed of executing scripts bash v. dash? Dash uses less RAM so if you have 20 instances open on a 512 MB machine it may make a difference.

That's comparing apples to oranges. Dash doesn't have the scope bash has; it has fewer builtins and lacks lots of other stuff bash has.


Got Leenucks? :: Arch: Power in simplicity :: Get Counted! Registered Linux User #392717 :: Blog thingy

Offline

#14 2010-05-20 16:07:50

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: Bash still worth learning?

I've set dash as my shell on my other box and plan to call bash only if I need an interactive shell.
I think I will need to slightly modify some of my scripts, but I hope it's doable - I'm not a scripting heavyweight and I need just simple automation.

> Dash doesn't have the scope bash has; it has fewer builtins and lacks lots of other stuff bash has.
That's for sure. The questions is, do I need that many features?

Offline

#15 2010-05-20 16:12:37

JohannesSM64
Member
From: Norway
Registered: 2009-10-11
Posts: 623
Website

Re: Bash still worth learning?

Bash still worth learning?

Nope, zsh is far better. It has everything bash has and much more.

Offline

#16 2010-05-20 16:43:35

Ogion
Member
From: Germany
Registered: 2007-12-11
Posts: 367

Re: Bash still worth learning?

Well, even zsh is more lightweight on RAM-usage than bash. (And that is for me even though i use the grml-zsh-config that puts a *lot* of bloat in my zsh, like functions defined, and still is more lightweight than bash)

But dash to me is not usable for interactive. It can't even use left/right, you have to backspace to correct some typo..
(Apart form that once blessed by zsh tab completion i can never look back tongue )

Ogion


(my-dotfiles)
"People willing to trade their freedom for temporary security deserve neither and will lose both." - Benjamin Franklin
"Enlightenment is man's leaving his self-caused immaturity." - Immanuel Kant

Offline

#17 2010-05-20 17:14:00

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: Bash still worth learning?

> But dash to me is not usable for interactive. It can't even use left/right, you have to backspace to correct some typo..
Funny, I can use all vi-keybindings in bash - left/right too :-)

Offline

#18 2010-05-20 17:16:30

Ogion
Member
From: Germany
Registered: 2007-12-11
Posts: 367

Re: Bash still worth learning?

"dash", not bash.

Ogion


(my-dotfiles)
"People willing to trade their freedom for temporary security deserve neither and will lose both." - Benjamin Franklin
"Enlightenment is man's leaving his self-caused immaturity." - Immanuel Kant

Offline

#19 2010-05-20 17:47:38

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: Bash still worth learning?

<facepalm> OMG, sorry for that, Ogion.
Dash *is not* an interactive shell. A shell doesn't have to be interactive, it has to run commands. 'fc' &c would make dash more suited for interactive use, but

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=252498
Since interactive use isn't very high on my agenda, I haven't devoted any time to it yet.  You're welcome to either build it with libedit or try the libreadline approach.

Offline

#20 2010-05-20 20:02:06

Trent
Member
From: Baltimore, MD (US)
Registered: 2009-04-16
Posts: 990

Re: Bash still worth learning?

karol wrote:

Dash *is not* an interactive shell.

++

dash is primarily used because it's pretty close to the least common denominator of POSIX-like shells.  (Back in the day, I hear people used to use the C shell for interactive use and Bourne shell only for scripts.  That was before bash.)

As for bash... it's really very useful.  I have spent hardly any time at all learning bash syntax but it worked its way into my brain anyway.  I kind of wish I had learned earlier, but it's not useful for everything.  bash is my interactive shell, so I use it when I need to do something that I can describe quickly enough that it wouldn't be worth the trouble to do it in Perl.  Those things aren't very common, though, in part because my Perl is better than my bash smile

Offline

#21 2010-05-20 22:36:27

moljac024
Member
From: Serbia
Registered: 2008-01-29
Posts: 2,676

Re: Bash still worth learning?

Runiq wrote:
Kiwi wrote:

So what Xyne is saying is that Python sucks more than Bash? Unless, I suppose, if that is a vacuum made by Microsoft.


(There is a quote somewhere something like, "The day Microsoft makes a product that doesn't suck is the day they start selling vacuums," if you did not get it)

Yeah, that's in moljac's sig if I'm not mistaken.

On topic: If you can do what you want in python, by all means, use python. I'd consider being able to read the occasional bash script is enough, as long as you have something better/more versatile that you can rely on (python, in your case).

Also: Nice one, Xyne. big_smile

Signiture reporting for duty.


The day Microsoft makes a product that doesn't suck, is the day they make a vacuum cleaner.
--------------------------------------------------------------------------------------------------------------
But if they tell you that I've lost my mind, maybe it's not gone just a little hard to find...

Offline

#22 2014-08-29 04:12:27

Teekin
Member
Registered: 2014-08-29
Posts: 1

Re: Bash still worth learning?

No.

No.

No, don't waste any time trying to learn Unix shell scripting of any kind.

Always use anything else.

If you run across a Unix shell script, transcribe it into something useful.

If for any reason you are unable, delete it and forget it ever existed.

If someone misses it, convince them to write it from scratch or die trying.

No matter what happens, never try to learn, use, write or in any way be in contact with Unix shell scripts of any kind, ever.

Unix shell scripts are useful for one thing and one thing only; learning whichever language you choose to rewrite them in.

Offline

#23 2014-08-29 04:14:25

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: Bash still worth learning?

Trolling and necrobumping on your first post? Don't.
https://wiki.archlinux.org/index.php/Fo … Bumping.27



Closing


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#24 2014-08-29 04:21:22

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,614

Re: Bash still worth learning?

Hi Teekin.  Welcome to Arch Linux.

This thread is so old that many of the moderators (who are present in this ancient thread) were newbies at the time they posted.  BTW, I hope you are being facetious about learning bash.

Closing this thread.  Please be aware of our policy on old threads.

Edit:  Once again, Jasonwryan is faster than me.

Last edited by ewaller (2014-08-29 04:22:17)


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
The shortest way to ruin a country is to give power to demagogues.— Dionysius of Halicarnassus
---
How to Ask Questions the Smart Way

Offline

Board footer

Powered by FluxBB