Talk:COMP 3000 2012 Midterm Material

From Soma-notes
Revision as of 18:46, 24 October 2012 by Cdelahou (talk | contribs) (→‎Discussion =: typo)


Discussion

Only the facts

I'll be putting up my notes of notes up here. Hopefully people can benefit from these. I'll be summing up the answers from the lab and adding a few more details here and there.

Lab 1

Types of shell commands

 Built ins
 Shell functions
 binaries (scripts and binaries
 alias 


Shell builtins vs binaries

 binaries exist elsewhere
 faster, no forking needed
 Kernel functions (IO redirection)


ls -l

 1          2  3     4   5     6             7
 -rwxr-xr-x 1 root root 104508 Mar 31  2012 /bin/ls
   U  G  O
 -rwxrwxrwx
 Memnonic: 'You go hugo!'
 - denotes a regular file
 d denotes a directory
 b denotes a block special file
 c denotes a character special file
 l denotes a symbolic link
 p denotes a named pipe


 2) 1 link to /bin/ls
 3) user root
 4) group root
 5) size in bytes
 6) date last modified
 7) path/filename

I/O redirection

 << keyword    HEREDOC. Input until program reads specified keyword
 >> append
 < read from path
 > write to path, blow away anything there
 | pipes

file descriptors

 0 stdin
 1 stdout
 2 stderr
 3-9 other

fd redirection

 #> where # is a file descriptor
 a>&b redirects file descriptor a to b.
 COMMAND &>> file.txt
 Appends BOTH STDERR and STDOUT to file.txt

For loops

 //For all files in fold that start with l, echo the title
 for i in l*; do
   echo $i
 done

Bg vs fg

 Bash waits or doesn't for return
 Both write to stdout as normal

Shell vars

 shell vars only apply to shell. Live in shell
 environment is more global, but typically a COPY is passed on to child processes
 envp is a series of keyvalue strings passed in with exec*