

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Material Type: Notes; Class: UNIX Operating Sys Fundamental; Subject: Computer Science; University: University of Alabama - Birmingham; Term: Fall 2006;
Typology: Study notes
1 / 3
This page cannot be seen from the preview
Don't miss anything!
10/13/2006 3 Department of Com
puter and Informati
on Sciences
10/13/2006 4 Department of Com
puter and Informati
on Sciences
Double quotes ignore most special characters, but command and variable substitution is performed Single quotes, no substitution performed: Examples: d=“You are currently logged on to hostname
” You are currently logged on to vulcan5.cis.uab.edu
e=“Today’s date is: $b” (b=date) f=“Today’s date is: $c” (c=‘date’) echo $e $f Today’s date is: date Today's date is: Fri Oct 13 10:03:37 CDT 2006
10/13/2006 5 Department of Com
puter and Informati
on Sciences
10/13/2006 6 Department of Com
puter and Informati
on Sciences
alias rm=’rm –i’ alias cp=’cp –i’ alias mv=’mv –i’
10/13/2006 7 Department of Com
puter and Informati
on Sciences
Redirecting Error MessagesRedirecting Error Messages
Utilities write to the error stream when an error occurs during their execution (^) lsls – –ll filename (if the filename does not exist or the file permissions are not sufficient)
We have seen output redirection using “>>” and “>>>>”. To redirect error messages use “2>2>” or “2>>2>>” (in bash) The shell assigns a 1 for the standard output stream and 2 for the standard error stream (“>>” is same as “1>1>”)
To redirect both error and output together use “2>&12>&1” after the filename PrintPrint stdoutstdout to screen,to screen, stderrstderr toto outerrouterr lsls^ – –l myfile xyz 2>l myfile xyz 2>^ outerrouterr
PrintPrint stdoutstdout ANDAND stderrstderr toto outerrouterr lsls – –ll myfilemyfile xyz >xyz > outerrouterr 2>&12>& 10/13/2006 8 Department of Com
puter and Informati
on Sciences
Communicative Shell Communicative Shell
$ bash -x $ tr '\t' ':' < quizscores | sort
$ bash -x $ c="You are currently logged on to hostname
" ++ hostname
10/13/2006 9 Department of Com
puter and Informati
on Sciences
Shell Command Line Expansion (I)Shell Command Line Expansion (I)
Matches zero or more characters List all files that end with .java – ls .javals .java List all files that start with cs – (^) ls csls cs
Matches one character List all files that start with chapter followed by any character – (^) ls chapter?ls chapter?
10/13/2006 10 Department of Com
puter and Informati
on Sciences
Shell Command Line Expansion (II) Shell Command Line Expansion (II)
Only one character is matched List all files that start with chapter and has a number following it within the range 1-5 – ls chapter[1ls chapter[1--5]5]
Curly braces match files specified in the braces, but will NOT expand ranges List all files that start with chapter and has specific numbers following it – ls chapter{2,3,4}ls chapter{2,3,4}
ls *[0ls *[0--9]?{java,c,cpp}9]?{java,c,cpp}
10/13/2006 11 Department of Com
puter and Informati
on Sciences
Local & Environment VariablesLocal & Environment Variables
Use “export variable_nameexport variable_name”
Remove variable – unsetunset
List all variables – setset
List environment variables – envenv
10/13/2006 12 Department of Com
puter and Informati
on Sciences
Miscellaneous Miscellaneous
splitsplit – –l linecount filename suffixl linecount filename suffix splitsplit – –l 20 longfile file+l 20 longfile file+