I want to tar a directory (including that directory itself) but I do not want the parent directory and I want to save it in the current working directory.
I am using:
'''cd /home/user/directory'''
'''tar -zcvf backup.tar.gz *'''
but it only saves the files and folders inside of /directory, not /directory itself as the head directory of the tar.
Further, I want the bash script to save the tar file in the current working directory of the user. I'm quite new to bash scripting so any help would be appreciated!
cd ..; tar -zcvf backup.tar.gz directory
– William Pursellcd /home/user/ && tar -zcvf backup.tar.gz directory
. – Roadowlcd .... || { echo "Something went wrong!" >&2; exit 1; } ; ....
Just in casecd
failed for one reason or another you will have an error and the rest of the code/command will not be executed... – Jetchisel