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, something like this, so it is easy to edit later:
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
/
That way it is easier to read and edit later. Is it possible to format a Bash script this way?
When I run the script now, the output file is:
– Jay LaCroix Nov 21 '12 at 03:26/share/Recovery/Snapshots/\hostname`_$DATE.tar.gz` – nerdwaller Nov 21 '12 at 03:36$(command)instead of\command``. – andrybak Jan 25 '15 at 10:46sshon the first line and commands on the following lines, I think I need a semicolon as well besides backslash. – Timo Nov 22 '20 at 08:23\? – Charlie Parker Dec 01 '21 at 19:40