SlideShare uma empresa Scribd logo
1 de 15
Baixar para ler offline
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 Shells
     Bourne: sh, ksh, bash
     C: csh, tcsh
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
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
Command Aliases
 Shortcut for command line
 Set/view using the alias
 command
 Examples:
     alias ls='ls --color=tty'
     alias rm='rm –i'
Shell Variables
  Customize environment
  Shared settings for programs
  Assigning Variables: var=“value”
  Referencing Variables: $var
  Viewing variables: set, printenv
  Variables are case sensitive
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
Parsing the Command Line
 Breaks the command line into
 components
 Special Characters modify
 operation
     How command runs
     Filename Expansion
     I/O redirection
     Quotes
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
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)
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
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
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
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

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

Linux shell env
Linux shell envLinux shell env
Linux shell env
 
Introduction to Shell script
Introduction to Shell scriptIntroduction to Shell script
Introduction to Shell script
 
Command-Line 101
Command-Line 101Command-Line 101
Command-Line 101
 
Shell Scripting in Linux
Shell Scripting in LinuxShell Scripting in Linux
Shell Scripting in Linux
 
1 4 sp
1 4 sp1 4 sp
1 4 sp
 
Bash shell scripting
Bash shell scriptingBash shell scripting
Bash shell scripting
 
Shellscripting
ShellscriptingShellscripting
Shellscripting
 
Introduction to shell
Introduction to shellIntroduction to shell
Introduction to shell
 
BASH Shell Script Training in Noida- Rexton It Solution
BASH Shell Script Training  in Noida- Rexton It SolutionBASH Shell Script Training  in Noida- Rexton It Solution
BASH Shell Script Training in Noida- Rexton It Solution
 
Shell programming 1.ppt
Shell programming  1.pptShell programming  1.ppt
Shell programming 1.ppt
 
101 3.1 gnu and unix commands v4
101 3.1 gnu and unix commands v4101 3.1 gnu and unix commands v4
101 3.1 gnu and unix commands v4
 
Easiest way to start with Shell scripting
Easiest way to start with Shell scriptingEasiest way to start with Shell scripting
Easiest way to start with Shell scripting
 
Quick start bash script
Quick start   bash scriptQuick start   bash script
Quick start bash script
 
3.1 gnu and unix commands v4
3.1 gnu and unix commands v43.1 gnu and unix commands v4
3.1 gnu and unix commands v4
 
Shell programming
Shell programmingShell programming
Shell programming
 
PowerShell Workshop Series: Session 2
PowerShell Workshop Series: Session 2PowerShell Workshop Series: Session 2
PowerShell Workshop Series: Session 2
 
Intro commandline
Intro commandlineIntro commandline
Intro commandline
 
Powershell alias
Powershell aliasPowershell alias
Powershell alias
 
Enable https (1) Tibco document
Enable https (1) Tibco document Enable https (1) Tibco document
Enable https (1) Tibco document
 
Basic command ppt
Basic command pptBasic command ppt
Basic command ppt
 

Semelhante a Lecture1 3 shells (20)

Unix
UnixUnix
Unix
 
Unix
UnixUnix
Unix
 
Unix
UnixUnix
Unix
 
Using Unix
Using UnixUsing Unix
Using Unix
 
COMELEC III - Bash unit 1
COMELEC III - Bash unit 1COMELEC III - Bash unit 1
COMELEC III - Bash unit 1
 
Spsl by sasidhar 3 unit
Spsl by sasidhar  3 unitSpsl by sasidhar  3 unit
Spsl by sasidhar 3 unit
 
Linux
LinuxLinux
Linux
 
Linux
LinuxLinux
Linux
 
Linux
LinuxLinux
Linux
 
Linux
LinuxLinux
Linux
 
Linux com
Linux comLinux com
Linux com
 
Basic basic solaris quick referent card
Basic basic solaris quick referent cardBasic basic solaris quick referent card
Basic basic solaris quick referent card
 
Unit 6 bash shell
Unit 6 bash shellUnit 6 bash shell
Unit 6 bash shell
 
Shell scripting
Shell scriptingShell scripting
Shell scripting
 
Formation sh
Formation shFormation sh
Formation sh
 
Mastering unix
Mastering unixMastering unix
Mastering unix
 
intro unix/linux 08
intro unix/linux 08intro unix/linux 08
intro unix/linux 08
 
Unix
UnixUnix
Unix
 
Ch03
Ch03Ch03
Ch03
 
UNIX - Class4 - Advance Shell Scripting-P1
UNIX - Class4 - Advance Shell Scripting-P1UNIX - Class4 - Advance Shell Scripting-P1
UNIX - Class4 - Advance Shell Scripting-P1
 

Mais de nghoanganh (20)

Tom tat lenh ubuntu
Tom tat lenh ubuntuTom tat lenh ubuntu
Tom tat lenh ubuntu
 
Thi xa vung bien hoan thanh 04042013
Thi xa vung bien   hoan thanh 04042013Thi xa vung bien   hoan thanh 04042013
Thi xa vung bien hoan thanh 04042013
 
Oxford thuong-yeu-truyen368-com-html
Oxford thuong-yeu-truyen368-com-htmlOxford thuong-yeu-truyen368-com-html
Oxford thuong-yeu-truyen368-com-html
 
Mis11e ch06
Mis11e ch06Mis11e ch06
Mis11e ch06
 
Mis11e ch03
Mis11e ch03Mis11e ch03
Mis11e ch03
 
Mis11e ch02
Mis11e ch02Mis11e ch02
Mis11e ch02
 
Mis11e ch01
Mis11e ch01Mis11e ch01
Mis11e ch01
 
Mis11e ch05
Mis11e ch05Mis11e ch05
Mis11e ch05
 
Chap14
Chap14Chap14
Chap14
 
Chap13
Chap13Chap13
Chap13
 
Chap11
Chap11Chap11
Chap11
 
Chap8
Chap8Chap8
Chap8
 
Chap7
Chap7Chap7
Chap7
 
Chap6
Chap6Chap6
Chap6
 
Chap5
Chap5Chap5
Chap5
 
Chap4
Chap4Chap4
Chap4
 
Chap3
Chap3Chap3
Chap3
 
Chap2
Chap2Chap2
Chap2
 
Chap1
Chap1Chap1
Chap1
 
Chap17
Chap17Chap17
Chap17
 

Último

Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfChris Hunter
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Shubhangi Sonawane
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Role Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxRole Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxNikitaBankoti2
 

Último (20)

Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Role Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxRole Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptx
 

Lecture1 3 shells

  • 2. Section Overview I/O Substitution Pathname Substitution Parameter/Variable Substitution Command Substitution
  • 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. 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. 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. Command Aliases Shortcut for command line Set/view using the alias command Examples:  alias ls='ls --color=tty'  alias rm='rm –i'
  • 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. 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. Parsing the Command Line Breaks the command line into components Special Characters modify operation  How command runs  Filename Expansion  I/O redirection  Quotes
  • 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. 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. 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. 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. 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. 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