Linux Tutorial Series

Linux Tutorial Series – 197 – Recap

Here is the video version, if you prefer it:

Let’s recap what we learned about shell scripting:

  • Shell scripts are files that contain commands (alongside some shell scripting keywords)
  • Use shell scripts to manipulate files; if you find yourself manipulating strings or doing arithmetic work, do something else
  • A line starting with #! is called a shebang
  • A line starting with a # is called a comment – it is ignored by the interpreter and serves only for human understanding of the shell script
  • Use single quotations unless you have a very good reason not to
  • There are special variables – for example, $1 corresponds to the first argument in your script – as well as some other ones
  • Exit codes tell you “how did the command do”
  • If statement follows the logic of “if this then that”
  • Else statement follows the logic of “if this then that, if not (else) then the other thing”
  • Logical operators are used to combine tests together
  • You can test for various conditions in a test
  • Use a case construct instead of a lot of elifs
  • for is used for iteration
  • Command substitution can be used to put the output of the command in a variable or to pass it as input to another command
  • You can read user input with read variableName

I hope you refreshed your memory!

NewsletterUpdates on interesting things I am doing

Subscribe to my newsletter to keep abreast of the interesting things I'm doing. I will send you the newsletter only when there is something interesting. This means 0% spam, 100% interesting content.

Leave a Reply

Your email address will not be published. Required fields are marked *