The following NEW packages will be installed:Ġ upgraded, 2 newly installed, 0 to remove and 0 not upgraded.Īfter this operation, 5,896 kB of additional disk space will be used. The following additional packages will be installed: On Linux one can install it using the apt command: You can also download the LZMA SDK provides the documentation, samples, header files, libraries, and tools you need to develop applications that use LZMA compression for UNIX like operating systems. Use 7-zip tool for Linux or MS-Windows operating systems which is a file archiver with a high compression ratio. You can also create a cronjob out of it, if you want to regularly create tar files for your purpose.Xz -cd | tar xvf - GUI Tool & CLI Tool Source Code You can add the above commands into your shell script, if you want to automate tasks. Tar is a useful command that allows you to easily archive and compress one or more files & directories into a single file. You can customize them as per your requirement. In this article, we have learnt how to exclude files & folders in tar, with many examples and use cases. $ tar -exclude='*/pdf' -zcvf data.tar /home/ubuntu/data tar.gz file using compression, as well as exclude certain files from tar command. Of course, you can always use tar command with other options also, when you exclude files & folders. Tar tar_filename -exclude-tag-all=exclude.tag /path/to/directory Tar tar_filename -X /path/to/exclude.txt /path/to/directory tar tar_filename -exclude=PATTERN1 -exclude=PATTERN2 /path/to/directory Please note, in some tar versions, you need to mention –exclude option after the. $ tar -exclude='*.txt' -exclude='*.pdf' data.tar /home/ubuntu/data $ tar -exclude='*.txt' data.tar /home/ubuntu/data But you can also use patterns & regular expressions to exclude multiple files & folders at one go. So far we have seen commands where we specify full paths to files and folders that need to be excluded from tar command. $ tar -exclude='.*' data.tar /home/ubuntu/data If you want to hide all hidden files in your directory, you can simply use wildcard character * in your exclude option as shown below. $ tar -exclude='/home/ubuntu/.ssh' data.tar /home/ubuntu/data If you want to hide hidden files in tar, you can easily mention them by adding dot(.) at their beginning. $ tar -exclude='/home/ubuntu/data/folder1' -exclude='/home/ubuntu/data/folder2' data.tar /home/ubuntu/data Here is an example to exclude /home/ubuntu/folder1 and /home/ubuntu/data/folder2. Just like excluding files, if you want to exclude multiple folders, you can mention them one after the other with separate –exclude option for each directory. Here is a command to exclude /home/data/folder1 $ tar -exclude='/home/ubuntu/data/folder1' data.tar /home/ubuntu/data If you want to exclude folders from tar command, you can also include them, just like files, in –exclude option. $ tar -exclude='/home/ubuntu/data/projects.pdf' -exclude='/home/ubuntu/data/projects1.pdf' data.tar /home/ubuntu/data If you want to exclude multiple files include them one after the other with separate –exclude options as shown below. Here is an example to exclude file projects.pdf from tar command.Įxclude Files in Tar $ tar -exclude='/home/ubuntu/data/projects.pdf' data.tar /home/ubuntu/data Now if you want to exclude a file or folder present in /home/ubuntu/data folder include their path in –exclude option. Here is an example to tar a folder /home/ubuntu/data to data.tar $ tar data.tar /home/ubuntu/data Here is the basic command to tar a folder. In this article, we will learn how to exclude files & folders while using tar directory. You can easily do all this using tar command. You may need to exclude hidden files and files based on names and patterns. But sometimes while using tar command, you may need to exclude one or more files & directories. By default, tar will include all files & folders present in your input folder. It even allows you to compress them into. Tar is a popular Linux utility to archive one more files & folders in.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |