Hacker News new | past | comments | ask | show | jobs | submit login

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.



This 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!


I 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


tar czvf

"create ze vucking file"

tar xzvf

"extract ze vucking files"


I 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.


There 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.


If 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.


Yes, 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.)


There is a similar cli tool called tldr[1]. It's very useful and simple to invoke.

[1] https://github.com/tldr-pages/tldr


Nice. 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 ...


Thank you. It is so convenient to write some functions is .bash_profile. So powerful new skill.


Cool, but on my Mac it makes flashing text..arggh.


Add -s to curl, should fix it.


s 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..




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: