Difference between $* and $@ in bash?

$* and $@, both these bash special variables expands to the positional parameters, starting from the first one.

These variables are same (expand positional parameters in same way) when using without double quotes. If these variables are using inside double quotes, it will expand positional parameters differently.

$* within double quotes ("$*") is equivalent to the list of positional parameters, separated by IFS variable.

Suppose IFS is ":" and hence expansion of "$*" will be like "$1:$2:$3:…"

And $@ within a pair of double quotes ("$@") is equivalent to the list of positional parameters separated by unquoted spaces, i.e., "$1" "$2".."$N". Or in other words, it is equivalent to the list of positional parameters where each parameters are double quoted.

For sake better understanding I wrote a script named star_and_at.sh and pushed to my public github repo

You can clone my bash github public repository directly using following command

Selective cPanel backup script – Part2

In the first part of Selective cPanel back up script, I explained the script for taking cPanel backups of domains to local server. In this part I am going to explain my script for taking back up to a remote server via scp. For sake of undestanging I am using two terms namely backup server and backup client to explain the working of script. Backup server means the system[server] to which the backup of selected domains are to be stored and backup client means the system [server] which is sending backup to backup server.

In this client – server system I devised a script on backup server which needs to put in cron. This script calls the scripts which placed in the backup clients for sending cpanel backup via SCP by SSH.

Working of the script in more detail:

Backup-Client

Files :

/root/bkp.sh
/root/cred

Continue reading “Selective cPanel backup script – Part2”

Redirections and file descriptors

By default, each Unix process has 3 file descriptors (FDs) assigned, 0, 1 and 2. These are known as stdin, stdout and stderr respectively.

For sake of ease of understanding, I am going to explain three different FDs using a simple figure.

By default, each Unix process has 3 file descriptors (FDs) assigned, 0, 1 and 2. These are known as stdin, stdout and stderr respectively.

For sake of ease of understanding, I am going to explain three different FDs using a simple figure.


Continue reading “Redirections and file descriptors”