Difference between revisions of "Unix cheatsheet"

From CoolWiki
Jump to navigationJump to search
m
m
Line 13: Line 13:
 
     ls *fits > listoffiles.txt
 
     ls *fits > listoffiles.txt
  
* Examining the contents of a file (works best on text files, but will also attempt it without complaint on binary files -- be careful!)
+
* Examining the contents of a file (works best on text files, but will also attempt it without complaint on binary files -- be careful!) ... To scroll down and see more of the file, hit the space bar; to quit out, hit "q".
 
     more listoffiles.txt
 
     more listoffiles.txt
To scroll down and see more of the file, hit the space bar; to quit out, hit "q".
+
 
  
 
* Unzipping the files from Leopard -- the "\" is important!!
 
* Unzipping the files from Leopard -- the "\" is important!!
Line 26: Line 26:
 
     tar -xf foo.tar
 
     tar -xf foo.tar
  
* Uncompressing a compressed tar file (may not work on older systems)
+
* Uncompressing a compressed tar file (may not work on older systems) -- e.g., doing the previous two steps in just one step.
 
     tar -xzf foo.tar.gz
 
     tar -xzf foo.tar.gz

Revision as of 16:37, 7 July 2008

Here is a quick list of common unix commands. These will work from a terminal window on Linux or Mac, or from a terminal window once you have cygwin installed on Windows. (see Windows hints, tips, and tricks.)

  • Changing directories (folders)
    cd /path/to/directory
  • Getting a directory listing
    ls
  • Getting a directory listing of just one kind of file extension
    ls *txt
  • Getting a directory listing in a plain text file
    ls *fits > listoffiles.txt
  • Examining the contents of a file (works best on text files, but will also attempt it without complaint on binary files -- be careful!) ... To scroll down and see more of the file, hit the space bar; to quit out, hit "q".
    more listoffiles.txt


  • Unzipping the files from Leopard -- the "\" is important!!
    unzip \*.zip
  • Unzipping files with a *gz extension
    gunzip *.gz
  • Uncompressing a tar file -- tar = Tape ARchive
    tar -xf foo.tar
  • Uncompressing a compressed tar file (may not work on older systems) -- e.g., doing the previous two steps in just one step.
    tar -xzf foo.tar.gz