Shell Features
Section Overview I/O Substitution Pathname Substitution Parameter/Variable Substitution Command Substitution
UNIX Shell Enables users to enter commands Text based Similar to MSDOS Command Prompt (but are much more powerful) Common ...
Shell Features Environment variables and aliases History of commands used Programming constructs Added features in newer s...
Command History/Editing Most shells maintain a history of previously entered commands history: View list of commands !#: R...
Command Aliases Shortcut for command line Set/view using the alias command Examples:     alias ls=ls --color=tty     ali...
Shell Variables  Customize environment  Shared settings for programs  Assigning Variables: var=“value”  Referencing Variab...
Special Shell Variables  HOME – User’s home directory path  SHELL – Current shell  UID – User’s UID number  PATH – Program...
Parsing the Command Line Breaks the command line into components Special Characters modify operation     How command runs...
Command Run Modifiers Write Space – Separate arguments Newline (<cr>) – End of line Special Characters   Character        ...
Filename Expansion Special characters representing multiple filenames Also referred to as globbing   Character            ...
I/O Redirection  Modifies how input and output is  used  Chain command to solve bigger      Characters                    ...
Standard File Descriptors  Special file pointers for input and  output  Extension from C language            Name         ...
Using File Descriptors  Finer control over input/output  redirection  stdout and stderr can be  redirected to same file   ...
Quote Characters Prevent special characters from being interpreted by the shell  Character         Name                 Ac...
Upcoming SlideShare
Loading in...5
×

Lecture1 3 shells

288

Published on

Published in: Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
288
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
1
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Lecture1 3 shells

  1. 1. Shell Features
  2. 2. Section Overview I/O Substitution Pathname Substitution Parameter/Variable Substitution Command Substitution
  3. 3. UNIX Shell Enables users to enter commands Text based Similar to MSDOS Command Prompt (but are much more powerful) Common Shells  Bourne: sh, ksh, bash  C: csh, tcsh
  4. 4. Shell Features Environment variables and aliases History of commands used Programming constructs Added features in newer shells  Command line editing  Command line completion Shell configuration files
  5. 5. Command History/Editing Most shells maintain a history of previously entered commands history: View list of commands !#: Rerun command number # Command line editing  Up/down arrow keys to cycle through list  Left/right arrow keys to move within listed command  <ctrl><a>: move to start of command line  <ctrl><e>: move to end of command line
  6. 6. Command Aliases Shortcut for command line Set/view using the alias command Examples:  alias ls=ls --color=tty  alias rm=rm –i
  7. 7. Shell Variables Customize environment Shared settings for programs Assigning Variables: var=“value” Referencing Variables: $var Viewing variables: set, printenv Variables are case sensitive
  8. 8. Special Shell Variables HOME – User’s home directory path SHELL – Current shell UID – User’s UID number PATH – Program search path PS1/PS2 – Format for command prompt (prompt for csh/tcsh)Must use “export” to set variables in shell
  9. 9. Parsing the Command Line Breaks the command line into components Special Characters modify operation  How command runs  Filename Expansion  I/O redirection  Quotes
  10. 10. Command Run Modifiers Write Space – Separate arguments Newline (<cr>) – End of line Special Characters Character Meaning ; Separate multiple command on same line & Run command in the background At end of line, continue on next line || && Logical operators based on exit status
  11. 11. Filename Expansion Special characters representing multiple filenames Also referred to as globbing Character Matches * 0 or more characters ? 1 character [ ] Matches any 1 character in [ ] (including ranges) [^ ] Matches any 1 character not in [ ] (including ranges)
  12. 12. I/O Redirection Modifies how input and output is used Chain command to solve bigger Characters Result tasks < file Use file as input for command command command > file Store command output in file command >> file Append command output to file command << label Input from standard input until label `command` Execute command then replace command name with its output cmd1 | cmd2 Use output from cmd1 as input to cmd2
  13. 13. Standard File Descriptors Special file pointers for input and output Extension from C language Name Descriptor Default Device Standard input (stdin) 0 Keyboard Standard output (stdout) 1 Screen Standard error (stderr) 2 Screen
  14. 14. Using File Descriptors Finer control over input/output redirection stdout and stderr can be redirected to same file Characters Result command 2> file stderr output stored in file cmd >& <file-descriptor> Output redirected to <file-descriptor> Cmd > file 2>&1 Stderr & stdout redirected to file
  15. 15. Quote Characters Prevent special characters from being interpreted by the shell Character Name Action ‘ Single Quote Shell ignores all special characters enclosed ‘ ’ “ Double Quote Shell ignores all special characters enclosed “ ” except for $ ‘ Backslash Shell ignores character immediately following
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×