So I'm new to linux and I have wrote a small script that is suppose to archive the contents that end with.log in /var/log to a tar file called log.tar in a new directory called archive. Then it's suppose to list the contents of the tar file and then extract it to a new file called backup.
#!/bin/bash mkdir archive mkdir backup cd archive tar -cvf log.tar /var/log/*.log tar -tf tar.log tar -xf tar.log -C ~/backup
So when I run the script I get this output.
tar: Removing leading `/' from member names /var/log/alternatives.log /var/log/auth.log /var/log/bootstrap.log /var/log/dpkg.log /var/log/fontconfig.log /var/log/gpu-manager.log /var/log/kern.log /var/log/vboxadd-install.log /var/log/vboxadd-setup.log /var/log/Xorg.0.log var/log/alternatives.log var/log/auth.log var/log/bootstrap.log var/log/dpkg.log var/log/fontconfig.log var/log/gpu-manager.log var/log/kern.log var/log/vboxadd-install.log var/log/vboxadd-setup.log var/log/Xorg.0.log
So I was wondering if it's possible to remove the /var/log/ part of the lines when archiving so I instead get this when listing what is in the tar file.
alternatives.log auth.log bootstrap.log cron.log dpkg.log kern.log mail.log
And when I do ls in the backup file I see the var directory and when I do las in the var directory and finally inside the log directory I get the log files. So how do I extract without the /var/log/ path name and directory?