Class Notes (839,315)
Canada (511,260)
CSC209H1 (41)
Karen Reid (20)


2 Pages

Computer Science
Course Code
Karen Reid

This preview shows 80% of the first page. Sign up to view the full 2 pages of the document.
 Pipelining commands – move to jan07c $ $name  Background processes – moved to jan09c -bash: Carl: command not found $ ls  Which cell? Week1-2-Shell.key file2 o sh – Bourne shell my_first_shell_script  Most common, other shells are a superset Week1-Intro.key file3 outer both filelist  Good for programming
 sorted_faculty o csh or tcsh – command-line default on CDF eveningClass filelongname  C-like syntax
Best for interactive use  not good for programming faculty first_name_first o bash – default on Linux (Bourne again shell) topics.pages  based on sh, with some csh features. file1 lecture_part2_script $ prog=my_first_shell_script  Shell programming $ $prog o Commands run from a file in a subshell today is our first lecture o A great way to automate a repeated sequence of commands. michelle still feels like she is in portugal o File starts with #!/bin/sh  absolute path to the shell program o Loops  not the same on every machine. for i in 1 2 3 4; do echo $i o Can also write programs interactively by starting a new shell at the done command line. o Tip: this is a good way to test your shell program iters="1 2 3 4" for i in $iters; do o Ex. the same code ran in file/command line echo $i done  In a file #!/bin/sh $ ls echo "Hello World!" Week1-2-Shell.key file1.c filelist sorted_faculty  At the command line Week1-Intro.key file2 filelongname skywolf% sh sh-2.05b$ echo "Hello World" both file2.c first_name_first Hello World topics.pages sh-2.05b$ exit eveningClass file3 lecture_part2_script exit faculty file3.c my_first_shell_script skywolf% file1 file4.c outer $ ls *.c file1.c file2.c file3.c file4.c o Commands $ for i in 4 5 6 7  You can run any program in a shell by calling it as you would on > do command line > echo why would I do this $i times > f$i.silly > done  When you run a program like grep or ls in a shell program, a new process is created. $ ls *.silly  There are also some built-in commands where no new process is f4.silly f5.silly f6.silly f7.silly $ cat *.silly created: why would I do this 4 times echo exit why would I do this 5 times set test why would I do this 6 times read shift why would I do this 7 times $ iters="1 2 3 4" o Variables $ for i in $iters  Varname=value (no spaces) > do  $varname to dereference > echo $i  Environment variables are global variables, can be used in a shell done  Ex. $SHELL 1 2  Variables here aren’t pointers to a memory location 3  Simply does text replacement/string replacement 4 $ for i in foo bar silly  Variables hold strings effectively, no floating point > do  Local variables disappears when shell terminates > echo $i  ex. > done bindir="/usr/bin" searchdirs="~/tests $HOME/test2 ." foo bar name=Carl silly $ echo name $ man seq name $ seq 2 10 $ echo $name 2 Carl 3 $ neighbour = Katrina 4 -bash: neighbour: command not found 5 $ neighbour=Ka
More Less
Unlock Document

Only 80% of the first page are available for preview. Some parts have been intentionally blurred.

Unlock Document
You're Reading a Preview

Unlock to view full version

Unlock Document

Log In


Join OneClass

Access over 10 million pages of study
documents for 1.3 million courses.

Sign up

Join to view


By registering, I agree to the Terms and Privacy Policies
Already have an account?
Just a few more details

So we can recommend you notes for your school.

Reset Password

Please enter below the email address you registered with and we will send you a link to reset your password.

Add your courses

Get notes from the top students in your class.