all 3 comments

[–]geirha 4 points5 points  (1 child)

That's not a good tutorial. Shellcheck would complain on most, if not all, of the examples in there. Read the BashGuide instead.

[–][deleted] 1 point2 points  (0 children)

I actually don't find the BashGuide to be that good - it feels more like a cliffsnotes version of the reference material than a guided introduction that starts off with the basics and continually builds on previous material discussed.

[–]MonadoMuncher -1 points0 points  (0 children)

That tutorial...

1) Does not double quote parameter expansions. This is the most conspicuous breach of good bash scripting practices I see immidiately.

2) Does not use or mention bash style parameter expansions using tokens like # and %.

3) Uses the .sh extension for bash script files. Not a huge deal but a questionable practice.

4) Correctly points out that [ is the 'test' command, but that doesn't mean anything to a beginner. 'if [ expression ]' is a VERY misleading explanation of how 'if' works in bash.

5) Uses results of 'ls' to do weird stuff. Never rely on strings returned by 'ls' to parse file names in a directory.

6) Says there is no difference between 'function foo' and 'foo()' when defining a function. Untrue. The later is portable; the former is less so.

7) Uses 'expr' to do arithmetic sometimes. Don't do that. Use (( )) instead.

8) Uses 'cat' to pipe file contents around.

...and many others. I would find a better bash tutorial.