270 likes | 390 Views
Lecture 9: Bourne Shell ( ch 8). IT244 - Introduction to Linux / Unix Instructor: Bo Sheng. Filename Generation/Wildcards. “ [] ” for range echo [ aeiou ]* cat colors.[135] echo [a- z ]* echo *[a- l ] “ ^ ” for “not” echo *[^a- z ] echo [^a- o ]*. Filename Generation/Wildcards.
E N D
Lecture 9: Bourne Shell (ch 8) IT244 - Introduction to Linux / Unix Instructor: Bo Sheng
Filename Generation/Wildcards • “[]” for range • echo [aeiou]* • cat colors.[135] • echo [a-z]* • echo *[a-l] • “^” for “not” • echo *[^a-z] • echo [^a-o]*
Filename Generation/Wildcards • Shell expands ambiguous filenames • ls hello? • ls hello\? The shell searches for matching filenames: hello1, hello2 hello1, hello2 ls hello? shell ls
Execute Commands • Foreground and background jobs • cp ~shengbo/it244/exetest . • ./exetest(CTRL+C to terminate) • ./exetest & (running in background) • jobs
Execute Commands • Foreground and background jobs • One foreground in a terminal • Only foreground gets input from keyboard • Multitasking
Execute Commands • Job number / PID number Job number Process ID
Execute Commands • Job number / PID number Job number Process ID
Execute Commands • Suspend a foreground job • exetest • CTRL+Z • jobs • Different from a running background job
Execute Commands • Resume a suspended job • In the background • bg [%job_number] • In the foreground • fg [%job_number] • Bring background job to foreground
Execute Commands • Abort a job • Foreground • CTRL+C • Background • kill process_ID • kill %job_number • tail –f hello &
Summary • Basic operations • ls, cd, pwd, cat, echo • cp, mv, rm • Overwrite • Interactive option • mkdir, rmdir
Summary • Basic operations • Make a copy of an existing directory • mkdirnew_directory • cp -rold_directory/* new_directory
Summary • Permissions • Read/write/execute • Execute permission on directories • chmod, getfacl/setfacl • Links • Hard links and symbolic links
Summary • More about file system and inode file1 inode Data blocks Inode table
Summary • More about file system and inode file1 inode Data blocks file2 Inode table inode Data blocks
Summary • More about file system and inode file1 inode Data blocks file2 Inode table inode Data blocks Directory
Summary • More about file system and inode file1 ln file1 file3 inode Data blocks file2 Inode table inode Data blocks Directory
Summary • More about file system and inode file1 ln file1 file3 inode Data blocks file2 Inode table inode Data blocks Directory
Summary • More about file system and inode file1 ln –s file1 file3 inode inum4, iaddr4 inode Data blocks file2 Inode table inode Data blocks Directory
Bourne Shell • Redirect standard error
Bourne Shell • Redirect standard error • echo “this is y” > y • cat y • cat x • cat x y > log • cat log • cat x y | tr “[a-z]” “[A-Z]”
Bourne Shell • Redirect standard error • File descriptor • 0: std input, 1: std output, 2: std error • cat x y 1> log 2> err • cat log • cat err
Bourne Shell • Redirect standard error • Combine std input and std error (&>) • cat x y &> log • cat log
Bourne Shell • Redirect standard error • Duplicate a file descriptor (>&) • cat x y 1> log 2>&1 • cat log • cat x y 2>&1 1> log • cat log
Bourne Shell • Redirect standard error • Duplicate a file descriptor (>&) • cat x y 1>log 2>log • cat log • cat y x 1>log 2>log • cat log
Bourne Shell • Redirect standard error • Duplicate a file descriptor (>&) • cat x y 1>&2 • cat x y 2>err 1>&2 • cat x y 1>&2 | tr “[a-z]” “[A-Z]”