Is learning BASH worth it?

  • (2 Pages)
  • +
  • 1
  • 2

19 Replies - 1870 Views - Last Post: 30 May 2019 - 12:37 PM Rate Topic: -----

#1 8Bit Bob   User is offline

  • D.I.C Head
  • member icon

Reputation: 10
  • View blog
  • Posts: 100
  • Joined: 07-February 18

Is learning BASH worth it?

Posted 29 May 2019 - 06:25 AM

So I've been messing around with Linux on an old laptop of mine for a bit now and I've learned the very basics of BASH. My question is: is it worth it to continue with it? I've been reading up on it and it seems to be a very specialized language and I'm not sure if it'd be a better use of my time to learn something like Python instead.

I don't really have anything in particular I want to use it for, I just want to learn a programming language as it's been a while since I programmed and I'm looking to get back into it.

Edit for the mods: apologies if this is the wrong area, please move the thread if it is.

This post has been edited by 8Bit Bob: 29 May 2019 - 06:26 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Is learning BASH worth it?

#2 BetaWar   User is offline

  • #include "soul.h"
  • member icon

Reputation: 1632
  • View blog
  • Posts: 8,493
  • Joined: 07-September 06

Re: Is learning BASH worth it?

Posted 29 May 2019 - 09:11 AM

In general, bash likely will not turn into a career, though it is useful to know (or at least be able to understand) - especially if you work on Linux in the future. However, as far as careers go, Python, Java, or Go would all be good choices for getting a job; C/C++ are also very useful, but a bit more specialized in the career areas that are available; web development languages (Javascript, HTML, CSS, PHP, etc.) are great if you go towards web development.

In my last company, we actually had a bash library that had everything from array helpers, to cross-distro Linux package management, to even some rudimentary object oriented capabilities. It was something that was written over ~15 years and was used in our system bootstrap process. It is also open source, so you can take a look at the crazy if you would like https://github.com/m...lmcmullen/ebash (check out the branch jblades-theWayTheWorldEnds for some insane OOBash stuff ;)
Was This Post Helpful? 0
  • +
  • -

#3 no2pencil   User is online

  • Professor Snuggly Pants
  • member icon

Reputation: 6821
  • View blog
  • Posts: 31,444
  • Joined: 10-May 07

Re: Is learning BASH worth it?

Posted 29 May 2019 - 09:17 AM

View PostBetaWar, on 29 May 2019 - 12:11 PM, said:

In general, bash likely will not turn into a career

Between 2008 & 2012 I landed a job specifically for Korn shell scripting.

Most of my current freelance work is screen scraping, which I do using bash shell.

Lastly, as an admin, I use bash shell everyday.


View Post8Bit Bob, on 29 May 2019 - 09:25 AM, said:

I don't really have anything in particular I want to use it for, I just want to learn a programming language


So it's really up to you & your goals to determine if it's worth it. I couldn't get by without it.
Was This Post Helpful? 0
  • +
  • -

#4 Catacombs   User is offline

  • New D.I.C Head

Reputation: 9
  • View blog
  • Posts: 44
  • Joined: 24-May 19

Re: Is learning BASH worth it?

Posted 29 May 2019 - 09:49 AM

Bash is absolutely worth learning. There are many scripts you can write that'll make your life easier. The only downside is the syntax is ... not the greatest.
Was This Post Helpful? 0
  • +
  • -

#5 8Bit Bob   User is offline

  • D.I.C Head
  • member icon

Reputation: 10
  • View blog
  • Posts: 100
  • Joined: 07-February 18

Re: Is learning BASH worth it?

Posted 29 May 2019 - 09:53 AM

While I'm not looking to make a career of programming (it's just a hobby for me), thanks for all the info! I heard a lot of people say that Bash is good for automating everyday tasks, but Linux isn't my main OS (I'm basically using my Linux PC for Bash programming atm) so I thought it might not be good for me. It's nice to see it's not a bad language to learn, though!
Was This Post Helpful? 0
  • +
  • -

#6 jon.kiparsky   User is offline

  • Beginner
  • member icon


Reputation: 11652
  • View blog
  • Posts: 19,806
  • Joined: 19-March 11

Re: Is learning BASH worth it?

Posted 29 May 2019 - 10:28 AM

Bash isn't great fun, but it's extremely useful. Python is a good scripting language, but you'll find that bash has a lot of advantages in terms of interacting with a *ix environment. The hard thing is, if you're working on your own it's hard to find your way into it. Most of my knowledge of bash comes from seeing the ways it's been used before me - there's a lot of "oh, you can do that???"
Was This Post Helpful? 0
  • +
  • -

#7 8Bit Bob   User is offline

  • D.I.C Head
  • member icon

Reputation: 10
  • View blog
  • Posts: 100
  • Joined: 07-February 18

Re: Is learning BASH worth it?

Posted 29 May 2019 - 10:37 AM

View Postjon.kiparsky, on 29 May 2019 - 12:28 PM, said:

Bash isn't great fun, but it's extremely useful. Python is a good scripting language, but you'll find that bash has a lot of advantages in terms of interacting with a *ix environment. The hard thing is, if you're working on your own it's hard to find your way into it. Most of my knowledge of bash comes from seeing the ways it's been used before me - there's a lot of "oh, you can do that???"

Yeah, I guess that would be helpful. I guess I'll just have to manage if I really wanna learn it :P

Also, would someone mind giving me an example of something Bash would be good at? Everyone says it's good for interacting with Linux/Unix environment, but I'm unsure of what that means exactly. What's an example of a practical and useful program in which it would be a good language choice?

Sorry if that's a dumb question, as I said I'm new-ish to all this.
Was This Post Helpful? 0
  • +
  • -

#8 Catacombs   User is offline

  • New D.I.C Head

Reputation: 9
  • View blog
  • Posts: 44
  • Joined: 24-May 19

Re: Is learning BASH worth it?

Posted 29 May 2019 - 11:45 AM

View Post8Bit Bob, on 29 May 2019 - 10:37 AM, said:

Also, would someone mind giving me an example of something Bash would be good at?


Just off the top of my head: You could cat a text file full of links to, say, an FTP site with data, curl each link and save the data to a CSV. Then, you can read through the files and combine them into one mega file, then operate on it using a CSV tool such as csvkit. You can organize all this in a shell script.

This post has been edited by Catacombs: 29 May 2019 - 11:45 AM

Was This Post Helpful? 1
  • +
  • -

#9 baavgai   User is offline

  • Dreaming Coder
  • member icon


Reputation: 7485
  • View blog
  • Posts: 15,514
  • Joined: 16-October 07

Re: Is learning BASH worth it?

Posted 29 May 2019 - 11:57 AM

*nix scripting starts at the Bourne shell. Then, when you've lost enough hair pissing about with that, you move to some other shell, of which bash has the most toys, and mind share via linux, though you still see korn adherents. Does anyone still use c-shell...

After shell land, the system programmer moves to heavier toys. Awk is where sed folks vent their frustration. Perl used to be where all frustrated shell users landed, but nowadays it seems Python has stolen Perl's thunder.

For *nix boxen, it's really about what tools you're likely to find. No matter how much you love emacs ( looks sideways at jon.kiparsky ) you may have to settle for vi on some systems.

If you're just looking for a language that will make your linux life easier, I'd go with python. I can't even count the number of times a messy bash script I've written has found its way to python. ( Again, used to be perl. )
Was This Post Helpful? 1
  • +
  • -

#10 xclite   User is offline

  • I wrote you an code
  • member icon


Reputation: 1397
  • View blog
  • Posts: 4,228
  • Joined: 12-May 09

Re: Is learning BASH worth it?

Posted 29 May 2019 - 01:31 PM

You can get pretty far by learning the common CLI tools that are present on machines (good examples in baavgai's post). Between those and things like pipes (|) and I/O redirection (< and >) you can get a lot done. If you're writing a lot of bash scripts, then you have a bit more arcane stuff to learn about how if statements, case statements, and argument handling work.
Was This Post Helpful? 1
  • +
  • -

#11 BetaWar   User is offline

  • #include "soul.h"
  • member icon

Reputation: 1632
  • View blog
  • Posts: 8,493
  • Joined: 07-September 06

Re: Is learning BASH worth it?

Posted 29 May 2019 - 07:28 PM

Other things that I very frequently use bash for are finding files that contain a regular expression and opening them in vim (my editor of choice, it could work with others with a bit of work). I also have a tendency to take notes using a quick shell script I wrote - and when I want to read them or share them nicely with others, I convert them to HTML before sending them out. And finally, I really like the idea of having directory shortcuts that I can quickly jump between using simplified names. I actually have all of that (and a few other things) up in this repo: https://github.com/jwkblades/utils
Was This Post Helpful? 2
  • +
  • -

#12 jon.kiparsky   User is offline

  • Beginner
  • member icon


Reputation: 11652
  • View blog
  • Posts: 19,806
  • Joined: 19-March 11

Re: Is learning BASH worth it?

Posted 29 May 2019 - 08:08 PM

Funny, in emacs that's just sort of built in :)

But yeah, that's a good example of the sort of thing that bash is good for - finding some stuff in the filesystem or environment and passing it on to some other process, classic bash.
Was This Post Helpful? 0
  • +
  • -

#13 Catacombs   User is offline

  • New D.I.C Head

Reputation: 9
  • View blog
  • Posts: 44
  • Joined: 24-May 19

Re: Is learning BASH worth it?

Posted 29 May 2019 - 11:08 PM

View Postbaavgai, on 29 May 2019 - 11:57 AM, said:

but nowadays it seems Python has stolen Perl's thunder.


Now Go is taking the lead ;)


View Postjon.kiparsky, on 29 May 2019 - 08:08 PM, said:

Funny, in emacs that's just sort of built in :)/>


What's built into Emacs?
Was This Post Helpful? 0
  • +
  • -

#14 baavgai   User is offline

  • Dreaming Coder
  • member icon


Reputation: 7485
  • View blog
  • Posts: 15,514
  • Joined: 16-October 07

Re: Is learning BASH worth it?

Posted 30 May 2019 - 02:11 AM

View Postxclite, on 29 May 2019 - 03:31 PM, said:

Between those and things like pipes (|) and I/O redirection (< and >) you can get a lot done.

Indeed. It is worth noting the early philosophy of Unix.

Quote

Make each program do one thing well. To do a new job, build afresh rather than complicate old programs by adding new "features".
-- https://en.wikipedia...Unix_philosophy


In an ideal *nix ecosystem, a general purpose programming language can, and should, be avoided. Even something like awk breaks this: if it takes some extra greps, seds, and pipes, is gooder. With this mindset, plain old Bourne is just fine, as you should just be stringing together many little programs that are doing the work.

The pipe all the things philosophy is interesting. It's declarative rather than imperative, which is probably why many programming types eschew it for the language solution so quickly. Still, it's worth playing around with first, as it can elegantly offer good results in the best case. In the worst case, you then know why you're moving heavier and what you have to do.
Was This Post Helpful? 0
  • +
  • -

#15 no2pencil   User is online

  • Professor Snuggly Pants
  • member icon

Reputation: 6821
  • View blog
  • Posts: 31,444
  • Joined: 10-May 07

Re: Is learning BASH worth it?

Posted 30 May 2019 - 05:13 AM

View Postbaavgai, on 30 May 2019 - 05:11 AM, said:

In an ideal *nix ecosystem, a general purpose programming language can, and should, be avoided. Even something like awk breaks this

An admin at my previous place of employment hated when I used cut rather than awk. But one area where awk is nice is dealing with tabs vs spaces. It nicely ignores all white-space the same.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2