Chapter 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
- The result will be
Tuesday
because the array is zero based. - 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
- The value of
b
variable will bec
and the value ofc
will bea
.
Since we didn't use dollar signs in the assignment lines, the variable will take the character value instead of the integer value.