Lec2Handouts - CS2044 - Advanced Unix Tools Spring 2009...

Info iconThis preview shows pages 1–10. Sign up to view the full content.

View Full Document Right Arrow Icon
CS2044 - Advanced Unix Tools Spring 2009 Lecture 2 David Slater dms236 at cornell.edu February 21, 2009 David Slater dms236 at cornell.edu CS2044 - Advanced Unix Tools
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Organization Please complete the questionnaire by class on Friday. Is everyone on CMS? I will upload a ”handouts” version of the first lecture later today. First homework given out on friday. David Slater dms236 at cornell.edu CS2044 - Advanced Unix Tools
Background image of page 2
Some Review Quoting: echo "I am $USER, did you know it is currently ‘date‘?" echo ’I am $USER, did you know it is currently ‘date‘?’ I am slater, did you know it is currently Wed Feb 18 12:12:46 EST 2009? I am $USER, did you know it is currently ‘date‘? David Slater dms236 at cornell.edu CS2044 - Advanced Unix Tools
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
More on Redirection We can redirect error messages to a file cmd 2> command.error cmd 2>> comand.error We can redirect both outout and error messages to the same file David Slater dms236 at cornell.edu CS2044 - Advanced Unix Tools
Background image of page 4
More Redirection We can redirect to /dev/null to suppress output Why does the following not work correctly? cmd < file > file Because before the command is executed, file is opened for reading and writing. When we open for writing it blanks the file. David Slater dms236 at cornell.edu CS2044 - Advanced Unix Tools
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
A Bit of Translation What does this print? echo ’1337 5p34k !5 n07 5p0k3n 4m0n9 2341 h4ck325’ | tr ’01234579!’ ’olreastgi’ leet speak is not spoken among real hackers David Slater dms236 at cornell.edu CS2044 - Advanced Unix Tools
Background image of page 6
Variables Variables are denoted by $varname , and set by varname=value No spaces! Example: $ world=Earth $ echo "Yo $world" Yo Earth There are a ton of built-in variables ($USER $SHELL . .. etc) David Slater dms236 at cornell.edu CS2044 - Advanced Unix Tools
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
And now it gets interesting. .. grep The purpose of grep is to print the lines that match a particular pattern. grep password file - prints all lines that contain the word password . How many lines contain the word monster in Frankenstein? grep ’[Mm]onster’ Frankenstein.txt | wc -l 33 David Slater dms236 at cornell.edu CS2044 - Advanced Unix Tools
Background image of page 8
grep -i - ignores case grep -A 20 -B 10 - prints the 10 lines before and 20 lines after each match grep -v - inverts the match grep -o - shows only the matched substring
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 10
This is the end of the preview. Sign up to access the rest of the document.

This document was uploaded on 05/21/2009.

Page1 / 27

Lec2Handouts - CS2044 - Advanced Unix Tools Spring 2009...

This preview shows document pages 1 - 10. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online