Difference between revisions of "BasicUnixUtilities"

(Tasks)
m
 

(3 intermediate revisions by 2 users not shown)



Line 27: Line 27:
  
 
* grep
 
* grep
 +
** grep will print output lines that match the first argument.  If you have a file that looks like
 +
<pre>
 +
my file
 +
your file
 +
</pre>
 +
** 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
 +
** wc -l < myfile
  
* how to output to file
+
* ??? 
 
+
** sort based not on # but on alphabet, sort all the A's, B's. C's etc.
  
 
==If you want to manipulate a text file:==
 
==If you want to manipulate a text file:==
Line 49: Line 72:
  
 
: Sort
 
: Sort
 +
[[Category:ToolHowTo]]

Latest revision as of 07:39, 21 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=7608806"