Difference between revisions of "BasicUnixUtilities"

(Tasks)
(Tasks)
Line 34: Line 34:
 
** grep my will show "my file"
 
** grep my will show "my file"
  
 +
* ls
 +
** shows the list of files in a directory
 +
 +
 +
* cat
 +
** displays the contents of a file
  
 
* |
 
* |
 +
** ties commands together. (see uniq)
  
* sort
+
* <
 +
** redirects input.  Used to feed the contents of a file to a utility
  
* cat
+
* >
 +
** redirects the output to a file
 +
** ls > list_of_files.txt
  
* ls
+
* sort
 +
** sorts things.  with -n will use numerical sorting (instead of the default alphabetical)
 +
** sort < my_file
  
 
* uniq
 
* uniq
 +
** takes a sorted file, and outputs the unique lines.  with -c it will output the number of items
 +
** sort < myfile | uniq
  
 
* wc
 
* wc
 
+
** counts words.  most often used as wc -l to count the number of lines
* how to output to file
+
** wc -l < myfile
  
 
==If you want to manipulate a text file:==
 
==If you want to manipulate a text file:==

Revision as of 05:30, 7 June 2007

Why are we doing this

  • To share how to do basic unix utilites.


How we know we are done

  • To sort a long list fo stuff

Definition

  • We are tring to get a list
  • how to use stuff to get information out of large lists of stuff that developers give less experiecenced developers or non developers.


People

  • Jason and Mark


Tasks

For example

  • Text file with one thing per line.
  • Opening a terminal window on your mac.
  • Look at the top of the file:
    • in the command line type head "filename" - this lets us know what the file looks like.


  • grep
    • grep will print output lines that match the first argument. If you have a file that looks like
my file
your file
    • grep my will show "my file"
  • ls
    • shows the list of files in a directory


  • cat
    • displays the contents of a file
  • |
    • ties commands together. (see uniq)
    • redirects the output to a file
    • ls > list_of_files.txt
  • sort
    • sorts things. with -n will use numerical sorting (instead of the default alphabetical)
    • sort


Retrieved from "http://aboutus.com/index.php?title=BasicUnixUtilities&oldid=7269699"