Friday, May 3, 2024
3
rated 0 times [  3] [ 0]  / answers: 1 / hits: 571  / 2 Years ago, sun, december 12, 2021, 5:53:13

This is pure laziness, but I'm looking to create a custom terminal command to extract tarballs - ie "targz" then a filename would extract a tar.gz tarball, and "tarbz2"... Well, guess.
I followed the instructions for creating custom commands found here, and while I'm sure that worked great for that asker (who wanted a command to start a couple of things for him, which required no additional arguments or anything), it's not working for me. The "targz" file in my ~/bin reads as follows:



tar -xzvf


What wizardry. So I type



targz putty-0.62.tar.gz


in the terminal, and it gives me:



tar: option requires an argument -- 'f'


Any way to make this work so I can just type "targz" then the target filename into the terminal and have it be extracted? Or, for extra sloth points, type something like "untar" then a target filename, then have it be extracted whether it's .gz or .bz2?


More From » command-line

 Answers
3

What you want to do is pass arguments to a shell script. Check out this link. I think you'll have your answer. As for the second part of your question, using tar -xvf will untar any file whether it's .gz, .bz2 or .xz.


[#32497] Monday, December 13, 2021, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
reangi

Total Points: 213
Total Questions: 102
Total Answers: 114

Location: Namibia
Member since Wed, Jan 19, 2022
2 Years ago
reangi questions
;