Last active
January 25, 2020 06:32
-
-
Save bsutton/4fa92df6d414449c7070b34647a2f08a to your computer and use it in GitHub Desktop.
Untar a file without having to remember the switches.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /usr/bin/env dshell | |
| import 'dart:io'; | |
| import 'package:dshell/dshell.dart'; | |
| /// duntar <tarfile> | |
| /// untars a file | |
| void main(List<String> args) { | |
| var parser = ArgParser(); | |
| var results = parser.parse(args); | |
| if (results.rest.length != 1) | |
| { | |
| print('untars a .tar or .tar.gz file'); | |
| print(''); | |
| printerr(red('You must provide the name of the file to untar')); | |
| print('The file will be untared in the current working directory'); | |
| exit(1); | |
| } | |
| var tarFile = results.rest[0]; | |
| if (tarFile.endsWith('.tar.gz')) | |
| { | |
| 'tar -zxvf $tarFile'.run; | |
| } | |
| else if (tarFile.endsWith('.tar')) | |
| { | |
| 'tar -xvf $tarFile'.run; | |
| } | |
| else | |
| { | |
| print("The tar file $tarFile does not have a know extension of '.tar.gz' or '.tar'"); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment