Let’s change the content in the exclude_file. The tar was trying to archive files in current dir. compress the file in transit (tar or not, single file or whole folder, 7za or something else even more efficient) do the above without saving intermediate files I am familiar with shell pipes like this: tar cf - MyBackups 7za a -si -mx9 -mson MyBackups.tar. With command like this: tar -C /home/another/path/ -czf archive.tgz. I tried wit -C option but it didn't seem to work. For simplicity's sake lets assume that there are no subdirectories inside /home/another/path/ - it contains only files. The tar command allows us to also include file extension patterns to be skipped in the exclude file. This is an equivalent of zip's zip -D -j command. It’s a short method of writing the –exclude-from option: $ tar -zcvf -exclude-from="exclude_file.txt". We’re using the -X option to enter an exclude file. The command is also used to extract, maintain, or modify tar archives. We’ll use this exclude_file.txt to exclude the items listed in it: $ tar -zcvf -X exclude_file.txt. The tar command is used to compress a group of files into an archive. Then we can add a list of file or directory names to be excluded, each separated by a newline: file1.txt Let’s see how to use an exclude file to ignore specific files and directories while archiving.įirst, we’ll create an exclude_file.txt file: $ touch exclude_file.txt Alternatively, we can use this command to list the contents of the file without extracting it:Īlternatively, we can provide the tar command with a file containing the list of files or directories to exclude when creating or extracting archive files. Since we used the -v option, we can see from the output above that file1.txt was skipped. We got the message “file changed as we read it” because we created the file in the same directory that contains the items to be archived. When excluding directories, we shouldn’t use the trailing slash(/) at the end of the directory name. ” at the end of the command as the path to the current working directory containing the files we want to archive. –exclude: excludes file1.txt file when creating the archive.-f: allows us to specify a filename for the archive created.-v: verbosely lists the files and directories processed.-z: compresses the files and directories using gzip.Let’s break down this command to understand it:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |