J
Jarret W. Buse
Guest
Applications 27 – Uncommon Options of tar Part 3
This article continues the uncommon options of the tar command.
Recall the basic syntax for using tar is:
tar <operation> [option] [folder/file]
The non-common options for tar are not often used, but you should have an idea of what else can be done with tar.
If the modification time stored in the tar should not be extracted as part of the file, use the “-m” option. For example, you want to extract files from the “Pics.tar” archive without the modification times to the current folder. The command would be “tar -xmf Pics.tar”.
To use the “--exclude” options and make the exclusion case-sensitive, use the “no-ignore-case” options with it. To backup all files from the “Pics” folder and exclude all files with a filename starting with “images”, use the command “tar -cf Backupexc.tar --exclude image* --no-ignore-case Pics/*”. Any files named “Image*” will not be included since it is case-sensitive.
To archive files within a specified folder and not include subfolders and file therein, use the “--no-recursion” option. So, to archive files in “Folder1” and not include subfolder “Folder2”, then use this option. The command to archive “Folder1” only into a file named “Folder1.tar”, use the command “tar -cf Folder1.tar --no-recursion Folder1/*”.
The “--no-wildcards” options is used with the “--exclude” option so wildcards are not used.
When using “--exclude”, the wildcards to match a slash (/).
The “--null option allows for the reading of null terminated names when using the option “--files-from”. The “--files-from” is a file containing a list of files to archive. The filenames can be null terminated. To create a tar called “File1.tar” from the files listed in the text file “filelist.txt”, the command would be “tar -cf File1.tar -T filelist.txt --null”.
To store the tar in a UNIX Version 7 format, use the “--old-archive” option. If you need to create a UNIX v7 archive, of the files in the “data” folder, named “Old.tar” use the command “tar -cf Old.tar --old-archive data/*”.
All files extracted will be sent to STDOUT. The process is useful for piping. If multiple files exist, they will be joined into one file. For instance, if you have an archive of text files, “Text.tar”, and wish to join them to one large file called “Main.txt” joined in alphabetical order, use the “-O” option. The command would be “tar -xOf Text.tar > Main.txt”.
As with the other tar options, practice them to be sure you understand them completely.
This article continues the uncommon options of the tar command.
Recall the basic syntax for using tar is:
tar <operation> [option] [folder/file]
The non-common options for tar are not often used, but you should have an idea of what else can be done with tar.
- -L, --tape-length N
- -m, --touch, --modification-time
If the modification time stored in the tar should not be extracted as part of the file, use the “-m” option. For example, you want to extract files from the “Pics.tar” archive without the modification times to the current folder. The command would be “tar -xmf Pics.tar”.
- -M, --multi-volume
- --mode PERMISSIONS
- -N, --after-date DATE, --newer DATE
- --newer-mtime DATE
- --no-ignore-case
To use the “--exclude” options and make the exclusion case-sensitive, use the “no-ignore-case” options with it. To backup all files from the “Pics” folder and exclude all files with a filename starting with “images”, use the command “tar -cf Backupexc.tar --exclude image* --no-ignore-case Pics/*”. Any files named “Image*” will not be included since it is case-sensitive.
- --no-recursion
To archive files within a specified folder and not include subfolders and file therein, use the “--no-recursion” option. So, to archive files in “Folder1” and not include subfolder “Folder2”, then use this option. The command to archive “Folder1” only into a file named “Folder1.tar”, use the command “tar -cf Folder1.tar --no-recursion Folder1/*”.
- --no-same-permissions
- --no-wildcards
The “--no-wildcards” options is used with the “--exclude” option so wildcards are not used.
- --no-wildcards-match-slash
When using “--exclude”, the wildcards to match a slash (/).
- --null
The “--null option allows for the reading of null terminated names when using the option “--files-from”. The “--files-from” is a file containing a list of files to archive. The filenames can be null terminated. To create a tar called “File1.tar” from the files listed in the text file “filelist.txt”, the command would be “tar -cf File1.tar -T filelist.txt --null”.
- --numeric-owner
- --old-archive, --portability
To store the tar in a UNIX Version 7 format, use the “--old-archive” option. If you need to create a UNIX v7 archive, of the files in the “data” folder, named “Old.tar” use the command “tar -cf Old.tar --old-archive data/*”.
- --no-same-owner
- -O, --to-stdout
All files extracted will be sent to STDOUT. The process is useful for piping. If multiple files exist, they will be joined into one file. For instance, if you have an archive of text files, “Text.tar”, and wish to join them to one large file called “Main.txt” joined in alphabetical order, use the “-O” option. The command would be “tar -xOf Text.tar > Main.txt”.
As with the other tar options, practice them to be sure you understand them completely.