tar Functions
The ever-ready Tape Archive tool, still handy in 2024.
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.
Reads standard input
A list of files to include in the tar file
Arguments
target- FileDirectory. Required.The tar.gz file to create.files- File. Optional. A list of files to include in the tar file.
Return codes
0- Success1- Environment error2- Argument error
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.
Reads standard input
A gzipped-tar file
Writes to standard output
The desired file
Arguments
pattern- The file pattern to extract
Return codes
0- Success1- Environment error2- Argument error