I wanted to tar some directory with gzip included. Please let me know what is the syntax for it. Following are also to be considered.1) It would be helpful if the tar.gz is getting split after 2G is completed with one tar file.( say: tar.gzaa becomes 2G, then it should continue to create tar.gzab)2) syntax for appending the log info into a log file3) to exclude some type of files with particular extension ( say my source directory which is going to be tar is having some child dir with .log files and i need to exclude those to be get tarred.Thanks in advance.
syntax for tar + gunzip included
linux;shell;tar;gzip;split
Maybe you can try something like this:tar --exclude='*.EXTENSION' -czvf - DIRECTORY/ 2> LOG_FILE.log | split --verbose --bytes=2048MB - FILE.tar.gz. >> LOG_FILE.logLet's test. Assuming we have a directory named directory with this files:eduardo@Notebook:~/testtar$ ll -h directory/total 570Mdrwxr-xr-x 2 eduardo eduardo 4,0K mar  6 23:25 ./drwxr-xr-x 3 eduardo eduardo 4,0K mar  6 23:28 ../-rw-r--r-- 1 eduardo eduardo    0 mar  6 23:16 file.any-rw-r--r-- 1 eduardo eduardo 570M mar  6 23:24 hugefile.dd-rw-r--r-- 1 eduardo eduardo    0 mar  6 23:15 image.jpg-rw-r--r-- 1 eduardo eduardo    0 mar  6 23:16 log.log-rw-r--r-- 1 eduardo eduardo    0 mar  6 23:14 text.txtTar command:tar --exclude='*.log' -czvf - directory/ 2> splitted_tar.log | split --verbose --bytes=50MB - splitted_tar_file.tar.gz. >> splitted_tar.logOutput files: eduardo@Notebook:~/testtar$ ll -htotal 299Mdrwxr-xr-x  3 eduardo eduardo 4,0K mar  6 23:53 ./drwxr-xr-x 41 eduardo eduardo 4,0K mar  6 23:16 ../drwxr-xr-x  2 eduardo eduardo 4,0K mar  6 23:25 directory/-rw-r--r--  1 eduardo eduardo  48M mar  6 23:52 splitted_tar_file.tar.gz.aa-rw-r--r--  1 eduardo eduardo  48M mar  6 23:53 splitted_tar_file.tar.gz.ab-rw-r--r--  1 eduardo eduardo  48M mar  6 23:53 splitted_tar_file.tar.gz.ac-rw-r--r--  1 eduardo eduardo  48M mar  6 23:53 splitted_tar_file.tar.gz.ad-rw-r--r--  1 eduardo eduardo  48M mar  6 23:53 splitted_tar_file.tar.gz.ae-rw-r--r--  1 eduardo eduardo  48M mar  6 23:53 splitted_tar_file.tar.gz.af-rw-r--r--  1 eduardo eduardo  13M mar  6 23:53 splitted_tar_file.tar.gz.ag-rw-r--r--  1 eduardo eduardo  399 mar  6 23:53 splitted_tar.logLog file:eduardo@Notebook:~/testtar$ cat splitted_tar.log directory/directory/text.txtdirectory/hugefile.dddirectory/file.anydirectory/image.jpgcreating file 'splitted_tar_file.tar.gz.aa'creating file 'splitted_tar_file.tar.gz.ab'creating file 'splitted_tar_file.tar.gz.ac'creating file 'splitted_tar_file.tar.gz.ad'creating file 'splitted_tar_file.tar.gz.ae'creating file 'splitted_tar_file.tar.gz.af'creating file 'splitted_tar_file.tar.gz.ag'Notes:The file log.log is not include in the final .tar.gz file due theparameter --exclude (make sure to put it before the source anddestination items)Tar verbose output goes to STDERR, this is why I used 2> LOG_FILE.logSplit verbose output goes to STDOUT, I just appended it with >> LOG_FILE.logTo restore your directory (join, gunzip and untar), you can use: cat splitted_tar_file.tar.gz.a? | tar -xzvf -