The execution of scripts is made versatile by the ability to run a script based on arguments supplied on the command line. In this way, the operation of the script varies depending on what arguments are given to the script. The shell automatically assigns special variable names, called positional parameters, to each argument supplied to […]
Archives for January 2018
Bash if loop examples (if then fi, if then elif fi, if then else fi)
The if Statement The if statement allows you to specify courses of action to be taken in a shell script, depending on the success or failure of some command. It is a conditional statement that allows a test before performing another statement. The syntax for the simplest form is: if [ condition ] then block_of_statements […]
How to tar, untar files and view contents of tar file under Linux
The tar command is useful for bundling up multiple files and/or directories. In a sense, it’s similar to the zip command. However, zip files are compressed by definition; tar files can be compressed, but don’t have to be. Creating a tar file In the examples to follow, the following file structure is used: a top […]