5 ms·
My favorite new one that I have been using a lot: function cheat() { curl cht.sh/$1 } It queries the cht.sh cheatsheet of various Unix commands. 'ch
by Grimm665 8y ago
My favorite new one that I have been using a lot:
function cheat() {
curl cht.sh/$1
}
It queries the cht.sh cheatsheet of various Unix commands. 'cheat tar' prints:
# To extract an uncompressed archive:
tar -xvf /path/to/foo.tar
# To create an uncompressed archive:
tar -cvf /path/to/foo.tar /path/to/foo/
# To extract a .gz archive:
tar -xzvf /path/to/foo.tgz
# To create a .gz archive:
tar -czvf /path/to/foo.tgz /path/to/foo/
# To list the content of an .gz archive:
tar -ztvf /path/to/foo.tgz
# To extract a .bz2 archive:
tar -xjvf /path/to/foo.tgz
# To create a .bz2 archive:
tar -cjvf /path/to/foo.tgz /path/to/foo/
# To extract a .tar in specified Directory:
tar -xvf /path/to/foo.tar -C /path/to/destination/
# To list the content of an .bz2 archive:
tar -jtvf /path/to/foo.tgz
# To create a .gz archive and exclude all jpg,gif,... from the tgz
tar czvf /path/to/foo.tgz --exclude=\*.{jpg,gif,png,wmv,flv,tar.gz,zip} /path/to/foo/
# To use parallel (multi-threaded) implementation of compression algorithms:
tar -z ... -> tar -Ipigz ...
tar -j ... -> tar -Ipbzip2 ...
tar -J ... -> tar -Ipixz ...
You do have to be online, but there are ways of downloading the directory of cheat sheets to use offline as well.
- joshstrange 8y agoThis is awesome, I ALWAYS have to google for how to untar an archive (I don't do it often enough to commit to memory) thank you!
- zzo38computer 8y agoThere are man pages though, but still I suppose that might be useful to you. Anyways, the only options for tar that I commonly use are "c", "x", and "t"; I will use other programs for decompression, and for extracting into a directory, will use cd.
- acqq 8y agoIf the man pages had useful examples the “cheat sheets” would not be needed. So “duh use man pages” is a wrong and annoying answer in this context.
- zzo38computer 8y agoYes, I suppose you are right, the man pages do not have sufficient examples. So, it is good that they add more there. (The man page still explains what all of the options are; now we have this "cheat sheets" with the examples, too.)
- borplk 8y agotar czvf "create ze vucking file" tar xzvf "extract ze vucking files"
- ericnyamu 8y agoLol.
- stevekemp 8y agoI have an alias "x" setup to run: atool --extract $* That will unpack "anything", into a sub-directory if necessary. Something I use more than any other alias.
- aug-riedinger 8y agoI have: function extract () { if [ -f $1 ] ; then case $1 in *.tar.bz2) tar xjf $1 ;; *.tar.gz) tar xzf $1 ;; *.bz2) bunzip2 $1 ;; *.rar) unrar e $1 ;; *.gz) gunzip $1 ;; *.tar) tar xf $1 ;; *.tbz2) tar xjf $1 ;; *.tgz) tar xzf $1 ;; *.zip) unzip $1 ;; *.Z) uncompress $1 ;; *.7z) 7z x $1 ;; *) echo "'$1' cannot be extracted via extract()" ;; esac else echo "'$1' is not a valid file" fi } instead
- yesenadam 8y agoCool, but on my Mac it makes flashing text..arggh.
- icco 8y agoAdd -s to curl, should fix it.
- yesenadam 8y agos for silent? I mean, all the text on the page is flashing on and off in sync..the whole page goes black. Its the first ESC code in the downloaded text, I guess..haven't quite figured out how to block that yet. If I then do an 'ls' (100s of files in that dir) it stops flashing, but when I scroll up, the first ls-ed files stay flashing..
- valtism 8y agoThere is a similar cli tool called tldr[1]. It's very useful and simple to invoke. [1] https://github.com/tldr-pages/tldr https://github.com/tldr-pages/tldr
- mpkc 8y agoThank you. It is so convenient to write some functions is .bash_profile. So powerful new skill.
- LinuxBender 8y agoNice. You might consider adding a check for the existence of a local cache file. If it doesn't exist, then try online. i.e. if [ ! -s "${cache_dir}"/"$1" ] ; then ...