Linux Bash Script, Single Command But Multiple Lines?

I have the following script I wrote by searching Google, and it backs up my Linux system to an archive: #!/bin/bash # init DATE=$(date +20%y%m%d) tar -cvpzf /share/Recovery/Snapshots/$HOSTNAME_$DATE.tar.gz –exclude=/proc –exclude=/lost+found –exclude=/sys –exclude=/mnt –exclude=/media –exclude=/dev –exclude=/share/Archive / This works, but I am wondering if I can format the script to show the command over multiple lines, … Read more

What is the difference between executing a Bash script vs sourcing it?

What is the difference between executing a Bash script like A and sourcing a Bash script like B? A > ./myscript B > source myscript Answer Both sourcing and executing the script will run the commands in the script line by line, as if you typed those commands by hand line by line. The differences … Read more

How to execute a command whenever a file changes?

I want a quick and simple way to execute a command whenever a file changes. I want something very simple, something I will leave running on a terminal and close it whenever I’m finished working with that file. Currently, I’m using this: while read; do ./myfile.py ; done And then I need to go to … Read more