My Computer Tips

Home | About | Categories | All Tips & Tutorials

Compress folder in tar.gz format using the terminal in Linux. Add current date to filename

ID: 380

Category: Linux Terminal

Added: 3rd of November 2024

Views: 51

To compress a folder in tar.gz format and also add the date in UK format to the file name, enter the following command.

tar -zcvf "backup_folder_name-$(date +"%d-%m-%Y").tar.gz" folder_name

To add the date in US format to the file name, enter the following command.
tar -zcvf "backup_folder_name-$(date +"%m-%d-%Y").tar.gz" folder_name

%d=date
%m=month
%Y=year