tar Functions
The ever-ready Tape ARchive tool, still handy in 2024.
tarCreate
Platform agnostic tar cfz which ignores owner and attributes
Usage
tarCreate target [ files ]
Platform agnostic tar cfz which ignores owner and attributes
tar command is not cross-platform so this differentiates between the GNU and BSD command line arguments without needing to know what operating system you are on. Creates a gz-compressed tar file (.tgz or .tar.gz) with user and group set to 0 and no extended attributes attached to the files.
Arguments
target- FileDirectory. Required.The tar.gz file to create.files- File. Optional. A list of files to include in the tar file.
Reads standard input
A list of files to include in the tar file
Return codes
0- Success1- Environment error2- Argument error
tarExtractPattern
Platform agnostic tar extract with wildcards
Usage
tarExtractPattern [ pattern ]
Platform agnostic tar extract with wildcards
e.g. tar -xf '*/file.json' or tar -xf --wildcards '*/file.json' depending on OS
tar command is not cross-platform so this differentiates between the GNU and BSD command line arguments.
Arguments
pattern- The file pattern to extract
Reads standard input
A gzipped-tar file
Writes to standard output
The desired file
Return codes
0- Success1- Environment error2- Argument error