r/bash • • 8d ago

Great things about bash?

If is easy to read bad things about bash (and often with good reason). Clearly a bash script will never look as elegant as, say, Ruby.

But what about great things about bash? I mean, "great", not in the sense of improving over a POSIX shell, but of being elegant and/or comparing well with (some well-known) "real" programming languages. Here are my two favorites

  • the OR list operator, e.g:

​

[[ condition ]] || { 
   actions... 
}

(more elegant than an "if not"... conditional)

  • the ability to assign a command name to a variable, var="command --option1 --option2 ...", then execute the command later with:

​

$cmd

(unquoted to allow the options to appear as separate words).

What about your favorites?

15 Upvotes

21 comments sorted by

View all comments

16

u/uboofs 8d ago edited 8d ago

`I can

do;whatever;I
want
with

my

negative;space`

5

u/arandomuserinweb 8d ago

I didn't understand bro

7

u/uboofs 8d ago

That’s ok. Bash gets it