cs246-s11-001-may12

cs246-s11-001-may12 - CS 246(Spring 2011 Section 1 Thursday...

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

View Full Document Right Arrow Icon
CS 246 (Spring 2011) – Section 1 Thursday 12 May Shell Scripting
Background image of page 1

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

View Full DocumentRight Arrow Icon
CS 246 (Spring 2011) - Section 001 - Thursday 12 May 2 Today's Agenda Some typos in the course notes Finish 1.7 (Input/Output Redirection) 1.8 Programming We will leave two subsections for next week 1.8.2 Arithmetic – I will only mention one thing from this section today 1.8.4 Environment Variables
Background image of page 2
CS 246 (Spring 2011) - Section 001 - Thursday 12 May 3 Typos in the course notes Section 1.5, example using find: When -type f is specified, only files (and not directories) are given, so “testdata” should not appear in the example Section 1.5, egrep: Same as grep -E (upper case E, not lower case) Section 1.7 The sort command should be sort -n when sorting numbers; otherwise the numbers are sorted in lexicographic order based on ASCII values
Background image of page 3

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

View Full DocumentRight Arrow Icon
CS 246 (Spring 2011) - Section 001 - Thursday 12 May 4 1.7 Input/Output Redirection The sort command consumes numbers from standard input and displays these numbers in sorted order on standard output sort -n 30 92 14 C-d (control-d) But what if we wanted to sort the numbers contained in a file ? Or save the result in a separate file?
Background image of page 4
CS 246 (Spring 2011) - Section 001 - Thursday 12 May 5 Input/Output Redirection What will each of the following do? sort -n < numbers.txt sort -n < numbers.txt > sorted.txt sort -n < numbers.txt >> sorted.txt Three files associated with every command 0 = input (default from keyboard) 1 = output (default to screen) 2 = error (default to screen) So we can say 1>, 1>>, 2>, 2>>
Background image of page 5

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

View Full DocumentRight Arrow Icon
CS 246 (Spring 2011) - Section 001 - Thursday 12 May 6 The pipe operator I/O redirection allows you to “pass” the output from one command as input to another command But intermediate files are created in this process A cleaner way is to use the pipe operator | Examples find . -name “*.txt” | sort Other examples Note: standard error not piped unless redirected to standard output (see example in notes)
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/08/2011 for the course CS 246 taught by Professor Wormer during the Spring '08 term at Waterloo.

Page1 / 24

cs246-s11-001-may12 - CS 246(Spring 2011 Section 1 Thursday...

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

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