170 likes | 559 Views
The UNIX Shells. 1. What is a Unix shell? 2. A few common shells in the Unix & Linux. A. Bourne shell B. Korn shell C. C shell D. Bash-the default shell on most Linux. Korn Shell. C Shell. Common Core. Bourne Shell. Shell. User. Resident modules. Kernel.
E N D
The UNIX Shells • 1. What is a Unix shell? • 2. A few common shells in the Unix & Linux. • A. Bourne shell • B. Korn shell • C. C shell • D. Bash-the default shell on most Linux
Korn Shell C Shell Common Core Bourne Shell
Shell User Resident modules Kernel Hardware
Shell Functions (Core) • Built-in commands, Scripts, Redirection • Wildcards, Pipes, Subshells • Background processing • Command substitution • Variables (Local & Environment) • Sequences (Conditional & Unconditional)
Selecting A Shell • 1. Password is required to change shell • 2. Utility: use chsh & input password • Bunrne --- /bin/sh • C --- /bin/csh • Korn --- /bin/ksh (not avl. Here) • Bash --- /bin/bash (Default for most • of the Linux)
Utilities & Shell Commands • In general, we don’t differentiate utilities & commands. In most of the books, both mean • the same thing. • They are utility programs to fulfill certain functions such as: • Text editing, File manipulation, email… …
Metacharacters • > --- Output redirection • >> --- Output redirection-append to a file • < --- Input redirection (Read standard • input from a file) • * --- File-substitution (similar to DOS) • ? --- File-substitution (single character) • | --- Pipe symbol (one out to another in)
More Metacharacters • || --- Conditional execution (executes a • command if the previous one fails) • && --- Opposite to || • & ---Runs a command in the background • # --- Comment • $ --- Expends the value of a variable • \ --- Disables the special meaning of next Char.
More … … Metacharacters • ; --- To sequence commands • (…) --- Groups commands • […] --- File substitution wildcard • `command` --- Command substitution; replaced • by the output from command • <<tok --- Input redirection; reads standard input • from script up to tok
Examples • 1. cat > file_1 You already familiar with • 2. cat >> file_1 ; appends new typed • contents to the existing file_1 • 3. ls file* list all files with file the first part • of the name • 4. ls ?ile2 • 5. ls file3 | wc • 6. sleep 30 & sleep 30 second in the background
More examples of using metacharacters • date; pwd; ls; cal--execute them in sequence • ls [ac]* -- list any string beginning with “a” or “c” • echo the date today is `date` • ls */*.c --- list all files ending in “.c” in any • subdirectory • ls [A-Za-z]* --- list any string begin with a letter