SlideShare une entreprise Scribd logo
1  sur  15
Télécharger pour lire hors ligne
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

Contenu connexe

Tendances

Tendances (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
 

Similaire à 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
 

Plus 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
 

Dernier

Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Association for Project Management
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsKarakKing
 
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
 
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
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseAnaAcapella
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 

Dernier (20)

Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
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...
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
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.
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).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