Chapter 1

  1. The error is in the second line: There should be no spaces in the variable declaration.
#!/bin/bash 
var1="Welcome to bash scripting ..." 
echo $var1 
  1. The result will be Tuesday because the array is zero based.
  2. There are two errors here: the first error is the space in the variable declaration and the second error is the usage of single quotes where we should use backticks instead.

Solution:

#!/bin/bash files='ls -la' echo $files
  1. The value of b variable will be c and the value of c will be a.

Since we didn't use dollar signs in the assignment lines, the variable will take the character value instead of the integer value.

Get Mastering Linux Shell Scripting now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.