SlideShare a Scribd company logo
RedHat Enterprise Linux Essential
     Unit 7: Standard I/O and Pipes
Objectives
Upon completion of this unit, you should be able to:

Redirect I/O channels to files

Connect commands using pipes

Use the for loops to iterate over sets of values
Standard Input and Output

Linux provides three I/O channels to Programs

   Standard input (STDIN) - keyboard by default (0)

   Standard output (STDOUT) - terminal window by default (1)

   Standard error (STDERR) - terminal window by default (2)

     ls –l myfile nofile
Redirecting Output to a File

 STDOUT and STDERR can be redirected to files:
    command operator filename

 Supported operators include:

>    Redirect STDOUT to file

 2> Redirect STDERR to file

 &> Redirect all output to file

 File contents are overwritten by default. >> appends.
Redirecting Output to a File
 command > file - Direct standard output of command to file

 command >> file - Append standard output of command to file

 command < file - Send file as input to command

 command 2> file - Redirect error messages from command to file

 command 2>> file - Append error messages from command to file
Redirecting Output to a File
                          Examples
 This command generates output and errors when run as non-
  root:
 $ find /etc -name passwd

 Operators can be used to store output and errors:
 $ find /etc -name passwd > find.out

 $ find /etc -name passwd 2> /dev/null

 $ find /etc -name passwd > find.out 2> find.err
Redirecting STDOUT to a Program (Piping)

 Pipes (the | character) can connect commands:

      command1 | command2

    Sends STDOUT of command1 to STDIN of command2 instead of the

     screen.

    STDERR is not forwarded across pipes


 Used to combine the functionality of multiple tools

      command1 | command2 | command3... etc
Redirecting STDOUT to a Program
                        Examples
 less: View input one page at a time:
      $ ls -l /etc | less

      Input can be searched with /

 mail: Send input via email:
      $ echo "test email" | mail -s "test" student
Combining Output and Errors
 Some operators affect both STDOUT and STDERR
   &>: Redirects all output:

    $ find /etc -name passwd &> find.all

   2>&1: Redirects STDERR to STDOUT

    Useful for sending all output through a pipe

    $ find /etc -name passwd 2>&1 | less

   (): Combines STDOUTs of multiple programs

    $ ( cal 2007 ; cal 2008 ) | less
Redirecting to Multiple Targets (tee)
 $ command1 | tee filename | command2

 Stores STDOUT of command1 in filename, then pipes to command2

 Uses:

    Troubleshooting complex pipelines

    Simultaneous viewing and logging of output


  ls -lR /etc | tee stage1.out | sort | tee stage2.out 

  | uniq -c | tee stage3.out | sort -r | tee stage4.out | less
Redirecting STDIN from a File

 Redirect standard input with <

 Some commands can accept data redirected to STDIN from a
  file:
          $ tr 'A-Z' 'a-z' < .bash_profile

 This command will translate the uppercase characters in
  .bash_profile to lowercase

 Equivalent to:
          $ cat .bash_profile | tr 'A-Z' 'a-z'
Sending Multiple Lines to STDIN
 Redirect multiple lines from keyboard to STDIN with <<WORD

 All text until WORD is sent to STDIN

 Sometimes called a heretext

   $ mail -s "Please see" student@localhost <<END

   > Hi all,

   >I’m Tam

   > END
Scripting: for loops

Performs actions on each member of a set of values

Example:
  for NAME in joe jane julie

  do

       ADDRESS="$NAME@example.com"

       MESSAGE='Projects are due today!'

       echo $MESSAGE | mail -s Reminder $ADDRESS

  done
Scripting: for loops continued

 Can also use command-output and file lists:
   for num in $(seq 1 10)
     • Assigns 1-10 to $num

     • seq X Y prints the numbers X through Y

   for file in *.txt
     • Assigns names of text files to $file
example
#!/bin/bash
# alive2.sh
# Checks to see if hosts 192.168.0.1-192.168.0.20 are
  alive
# Iterate through IP addresses
for n in {1..20}; do
         host=192.168.0.$n
         ping -c2 $host &> /dev/null
         if [ $? = 0 ]; then
                 echo "$host is UP"
         else
                 echo "$host is DOWN"
         fi
done
Unit 7 standard i o

More Related Content

What's hot

Course 102: Lecture 6: Seeking Help
Course 102: Lecture 6: Seeking HelpCourse 102: Lecture 6: Seeking Help
Course 102: Lecture 6: Seeking Help
Ahmed El-Arabawy
 
Linux basic commands with examples
Linux basic commands with examplesLinux basic commands with examples
Linux basic commands with examples
abclearnn
 
Unix - Filters/Editors
Unix - Filters/EditorsUnix - Filters/Editors
Unix - Filters/Editors
ananthimurugesan
 
Linux basics
Linux basicsLinux basics
Linux basics
BhaskarNeeluru
 
Basic linux commands
Basic linux commandsBasic linux commands
Basic linux commands
Harikrishnan Ramakrishnan
 
Using Unix
Using UnixUsing Unix
Using Unix
Dr.Ravi
 
Unix Commands
Unix CommandsUnix Commands
Unix Commands
Dr.Ravi
 
Prabu linux
Prabu linuxPrabu linux
Prabu linux
Prabu Cse
 
Babitha.linux
Babitha.linuxBabitha.linux
Babitha.linux
banubabitha
 
Babitha.linux
Babitha.linuxBabitha.linux
Babitha.linux
banubabitha
 
Basic command ppt
Basic command pptBasic command ppt
Basic command ppt
Rohit Kumar
 

What's hot (11)

Course 102: Lecture 6: Seeking Help
Course 102: Lecture 6: Seeking HelpCourse 102: Lecture 6: Seeking Help
Course 102: Lecture 6: Seeking Help
 
Linux basic commands with examples
Linux basic commands with examplesLinux basic commands with examples
Linux basic commands with examples
 
Unix - Filters/Editors
Unix - Filters/EditorsUnix - Filters/Editors
Unix - Filters/Editors
 
Linux basics
Linux basicsLinux basics
Linux basics
 
Basic linux commands
Basic linux commandsBasic linux commands
Basic linux commands
 
Using Unix
Using UnixUsing Unix
Using Unix
 
Unix Commands
Unix CommandsUnix Commands
Unix Commands
 
Prabu linux
Prabu linuxPrabu linux
Prabu linux
 
Babitha.linux
Babitha.linuxBabitha.linux
Babitha.linux
 
Babitha.linux
Babitha.linuxBabitha.linux
Babitha.linux
 
Basic command ppt
Basic command pptBasic command ppt
Basic command ppt
 

Viewers also liked

DHCP
DHCPDHCP
Server 2012 essentials
Server 2012 essentialsServer 2012 essentials
Server 2012 essentials
Steven Teiger
 
Red hat linux essentials
Red hat linux essentialsRed hat linux essentials
Red hat linux essentials
elshiekh1980
 
Using CloudStack With Clustered LVM
Using CloudStack With Clustered LVMUsing CloudStack With Clustered LVM
Using CloudStack With Clustered LVM
Marcus L Sorensen
 
Unit 8 text processing tools
Unit 8 text processing toolsUnit 8 text processing tools
Unit 8 text processing tools
root_fibo
 
Linux Forensics
Linux ForensicsLinux Forensics
Linux Forensics
Santosh Khadsare
 
Rhel cluster basics 1
Rhel cluster basics   1Rhel cluster basics   1
Rhel cluster basics 1
Manoj Singh
 
Red hat linux essentials
Red hat linux essentialsRed hat linux essentials
Red hat linux essentials
Haitham Raik
 
RedHat Cluster!
RedHat Cluster!RedHat Cluster!
RedHat Cluster!
Mohammed Al_Maraghy
 
RHEL-7 Administrator Guide for RedHat 7
RHEL-7  Administrator Guide for RedHat 7RHEL-7  Administrator Guide for RedHat 7
RHEL-7 Administrator Guide for RedHat 7
Hemnath R.
 
Alphorm.com Support Formation Red Hat Administration Système III RHCSE-(Rh254)
Alphorm.com Support Formation Red Hat Administration Système III RHCSE-(Rh254)Alphorm.com Support Formation Red Hat Administration Système III RHCSE-(Rh254)
Alphorm.com Support Formation Red Hat Administration Système III RHCSE-(Rh254)
Alphorm
 
Introduction to Red Hat
Introduction to Red HatIntroduction to Red Hat
Introduction to Red Hat
Albert Wong
 
RedHat Linux
RedHat LinuxRedHat Linux
RedHat Linux
Apo
 
Linux Cluster Concepts
Linux Cluster ConceptsLinux Cluster Concepts
Linux Cluster Concepts
nixsavy
 
JBoss Application Server 7
JBoss Application Server 7JBoss Application Server 7
JBoss Application Server 7
Ray Ploski
 

Viewers also liked (15)

DHCP
DHCPDHCP
DHCP
 
Server 2012 essentials
Server 2012 essentialsServer 2012 essentials
Server 2012 essentials
 
Red hat linux essentials
Red hat linux essentialsRed hat linux essentials
Red hat linux essentials
 
Using CloudStack With Clustered LVM
Using CloudStack With Clustered LVMUsing CloudStack With Clustered LVM
Using CloudStack With Clustered LVM
 
Unit 8 text processing tools
Unit 8 text processing toolsUnit 8 text processing tools
Unit 8 text processing tools
 
Linux Forensics
Linux ForensicsLinux Forensics
Linux Forensics
 
Rhel cluster basics 1
Rhel cluster basics   1Rhel cluster basics   1
Rhel cluster basics 1
 
Red hat linux essentials
Red hat linux essentialsRed hat linux essentials
Red hat linux essentials
 
RedHat Cluster!
RedHat Cluster!RedHat Cluster!
RedHat Cluster!
 
RHEL-7 Administrator Guide for RedHat 7
RHEL-7  Administrator Guide for RedHat 7RHEL-7  Administrator Guide for RedHat 7
RHEL-7 Administrator Guide for RedHat 7
 
Alphorm.com Support Formation Red Hat Administration Système III RHCSE-(Rh254)
Alphorm.com Support Formation Red Hat Administration Système III RHCSE-(Rh254)Alphorm.com Support Formation Red Hat Administration Système III RHCSE-(Rh254)
Alphorm.com Support Formation Red Hat Administration Système III RHCSE-(Rh254)
 
Introduction to Red Hat
Introduction to Red HatIntroduction to Red Hat
Introduction to Red Hat
 
RedHat Linux
RedHat LinuxRedHat Linux
RedHat Linux
 
Linux Cluster Concepts
Linux Cluster ConceptsLinux Cluster Concepts
Linux Cluster Concepts
 
JBoss Application Server 7
JBoss Application Server 7JBoss Application Server 7
JBoss Application Server 7
 

Similar to Unit 7 standard i o

101 3.4 use streams, pipes and redirects
101 3.4 use streams, pipes and redirects101 3.4 use streams, pipes and redirects
101 3.4 use streams, pipes and redirects
Acácio Oliveira
 
lec4.docx
lec4.docxlec4.docx
lec4.docx
ismailaboshatra
 
Session3
Session3Session3
Session3
Learn 2 Be
 
shellScriptAlt.pptx
shellScriptAlt.pptxshellScriptAlt.pptx
shellScriptAlt.pptx
NiladriDey18
 
Shell Scripts
Shell ScriptsShell Scripts
Shell Scripts
Dr.Ravi
 
Text mining on the command line - Introduction to linux for bioinformatics
Text mining on the command line - Introduction to linux for bioinformaticsText mining on the command line - Introduction to linux for bioinformatics
Text mining on the command line - Introduction to linux for bioinformatics
BITS
 
Bioinformatica 29-09-2011-p1-introduction
Bioinformatica 29-09-2011-p1-introductionBioinformatica 29-09-2011-p1-introduction
Bioinformatica 29-09-2011-p1-introduction
Prof. Wim Van Criekinge
 
Shell Scripting
Shell ScriptingShell Scripting
Shell Scripting
Gaurav Shinde
 
ShellAdvanced aaäaaaaaaaaaaaaaaaaaaaaaaaaaaa
ShellAdvanced aaäaaaaaaaaaaaaaaaaaaaaaaaaaaaShellAdvanced aaäaaaaaaaaaaaaaaaaaaaaaaaaaaa
ShellAdvanced aaäaaaaaaaaaaaaaaaaaaaaaaaaaaa
ewout2
 
Linux And perl
Linux And perlLinux And perl
Linux And perl
Sagar Kumar
 
Unix And Shell Scripting
Unix And Shell ScriptingUnix And Shell Scripting
Unix And Shell Scripting
Jaibeer Malik
 
Licão 08 system redirects
Licão 08 system redirectsLicão 08 system redirects
Licão 08 system redirects
Acácio Oliveira
 
Bash Shell Scripting
Bash Shell ScriptingBash Shell Scripting
Bash Shell Scripting
Raghu nath
 
101 3.2 process text streams using filters
101 3.2 process text streams using filters101 3.2 process text streams using filters
101 3.2 process text streams using filters
Acácio Oliveira
 
390aLecture05_12sp.ppt
390aLecture05_12sp.ppt390aLecture05_12sp.ppt
390aLecture05_12sp.ppt
mugeshmsd5
 
Unix Tutorial
Unix TutorialUnix Tutorial
Unix Tutorial
Sanjay Saluth
 
Course 102: Lecture 12: Basic Text Handling
Course 102: Lecture 12: Basic Text Handling Course 102: Lecture 12: Basic Text Handling
Course 102: Lecture 12: Basic Text Handling
Ahmed El-Arabawy
 
II BCA OS pipes and filters.pptx
II BCA OS pipes and filters.pptxII BCA OS pipes and filters.pptx
II BCA OS pipes and filters.pptx
Savitha74
 
Unix
UnixUnix
3.4 use streams, pipes and redirects v2
3.4 use streams, pipes and redirects v23.4 use streams, pipes and redirects v2
3.4 use streams, pipes and redirects v2
Acácio Oliveira
 

Similar to Unit 7 standard i o (20)

101 3.4 use streams, pipes and redirects
101 3.4 use streams, pipes and redirects101 3.4 use streams, pipes and redirects
101 3.4 use streams, pipes and redirects
 
lec4.docx
lec4.docxlec4.docx
lec4.docx
 
Session3
Session3Session3
Session3
 
shellScriptAlt.pptx
shellScriptAlt.pptxshellScriptAlt.pptx
shellScriptAlt.pptx
 
Shell Scripts
Shell ScriptsShell Scripts
Shell Scripts
 
Text mining on the command line - Introduction to linux for bioinformatics
Text mining on the command line - Introduction to linux for bioinformaticsText mining on the command line - Introduction to linux for bioinformatics
Text mining on the command line - Introduction to linux for bioinformatics
 
Bioinformatica 29-09-2011-p1-introduction
Bioinformatica 29-09-2011-p1-introductionBioinformatica 29-09-2011-p1-introduction
Bioinformatica 29-09-2011-p1-introduction
 
Shell Scripting
Shell ScriptingShell Scripting
Shell Scripting
 
ShellAdvanced aaäaaaaaaaaaaaaaaaaaaaaaaaaaaa
ShellAdvanced aaäaaaaaaaaaaaaaaaaaaaaaaaaaaaShellAdvanced aaäaaaaaaaaaaaaaaaaaaaaaaaaaaa
ShellAdvanced aaäaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Linux And perl
Linux And perlLinux And perl
Linux And perl
 
Unix And Shell Scripting
Unix And Shell ScriptingUnix And Shell Scripting
Unix And Shell Scripting
 
Licão 08 system redirects
Licão 08 system redirectsLicão 08 system redirects
Licão 08 system redirects
 
Bash Shell Scripting
Bash Shell ScriptingBash Shell Scripting
Bash Shell Scripting
 
101 3.2 process text streams using filters
101 3.2 process text streams using filters101 3.2 process text streams using filters
101 3.2 process text streams using filters
 
390aLecture05_12sp.ppt
390aLecture05_12sp.ppt390aLecture05_12sp.ppt
390aLecture05_12sp.ppt
 
Unix Tutorial
Unix TutorialUnix Tutorial
Unix Tutorial
 
Course 102: Lecture 12: Basic Text Handling
Course 102: Lecture 12: Basic Text Handling Course 102: Lecture 12: Basic Text Handling
Course 102: Lecture 12: Basic Text Handling
 
II BCA OS pipes and filters.pptx
II BCA OS pipes and filters.pptxII BCA OS pipes and filters.pptx
II BCA OS pipes and filters.pptx
 
Unix
UnixUnix
Unix
 
3.4 use streams, pipes and redirects v2
3.4 use streams, pipes and redirects v23.4 use streams, pipes and redirects v2
3.4 use streams, pipes and redirects v2
 

More from root_fibo

Unit 13 network client
Unit 13 network clientUnit 13 network client
Unit 13 network client
root_fibo
 
Unit 12 finding and processing files
Unit 12 finding and processing filesUnit 12 finding and processing files
Unit 12 finding and processing files
root_fibo
 
Unit 11 configuring the bash shell – shell script
Unit 11 configuring the bash shell – shell scriptUnit 11 configuring the bash shell – shell script
Unit 11 configuring the bash shell – shell script
root_fibo
 
Unit3 browsing the filesystem
Unit3 browsing the filesystemUnit3 browsing the filesystem
Unit3 browsing the filesystem
root_fibo
 
Unit 9 basic system configuration tools
Unit 9 basic system configuration toolsUnit 9 basic system configuration tools
Unit 9 basic system configuration tools
root_fibo
 
Unit 6 bash shell
Unit 6 bash shellUnit 6 bash shell
Unit 6 bash shell
root_fibo
 
Unit 5 vim an advanced text editor
Unit 5 vim an advanced text editorUnit 5 vim an advanced text editor
Unit 5 vim an advanced text editor
root_fibo
 
Unit 4 user and group
Unit 4 user and groupUnit 4 user and group
Unit 4 user and group
root_fibo
 
Unit2 help
Unit2 helpUnit2 help
Unit2 help
root_fibo
 

More from root_fibo (9)

Unit 13 network client
Unit 13 network clientUnit 13 network client
Unit 13 network client
 
Unit 12 finding and processing files
Unit 12 finding and processing filesUnit 12 finding and processing files
Unit 12 finding and processing files
 
Unit 11 configuring the bash shell – shell script
Unit 11 configuring the bash shell – shell scriptUnit 11 configuring the bash shell – shell script
Unit 11 configuring the bash shell – shell script
 
Unit3 browsing the filesystem
Unit3 browsing the filesystemUnit3 browsing the filesystem
Unit3 browsing the filesystem
 
Unit 9 basic system configuration tools
Unit 9 basic system configuration toolsUnit 9 basic system configuration tools
Unit 9 basic system configuration tools
 
Unit 6 bash shell
Unit 6 bash shellUnit 6 bash shell
Unit 6 bash shell
 
Unit 5 vim an advanced text editor
Unit 5 vim an advanced text editorUnit 5 vim an advanced text editor
Unit 5 vim an advanced text editor
 
Unit 4 user and group
Unit 4 user and groupUnit 4 user and group
Unit 4 user and group
 
Unit2 help
Unit2 helpUnit2 help
Unit2 help
 

Recently uploaded

20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
Edge AI and Vision Alliance
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
Pixlogix Infotech
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
IndexBug
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
Tomaz Bratanic
 
Mariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceXMariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceX
Mariano Tinti
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
Daiki Mogmet Ito
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
SOFTTECHHUB
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 

Recently uploaded (20)

20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
Best 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERPBest 20 SEO Techniques To Improve Website Visibility In SERP
Best 20 SEO Techniques To Improve Website Visibility In SERP
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial IntelligenceAI 101: An Introduction to the Basics and Impact of Artificial Intelligence
AI 101: An Introduction to the Basics and Impact of Artificial Intelligence
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
 
Mariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceXMariano G Tinti - Decoding SpaceX
Mariano G Tinti - Decoding SpaceX
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 

Unit 7 standard i o

  • 1. RedHat Enterprise Linux Essential Unit 7: Standard I/O and Pipes
  • 2. Objectives Upon completion of this unit, you should be able to: Redirect I/O channels to files Connect commands using pipes Use the for loops to iterate over sets of values
  • 3. Standard Input and Output Linux provides three I/O channels to Programs  Standard input (STDIN) - keyboard by default (0)  Standard output (STDOUT) - terminal window by default (1)  Standard error (STDERR) - terminal window by default (2) ls –l myfile nofile
  • 4. Redirecting Output to a File  STDOUT and STDERR can be redirected to files:  command operator filename  Supported operators include: > Redirect STDOUT to file  2> Redirect STDERR to file  &> Redirect all output to file  File contents are overwritten by default. >> appends.
  • 5. Redirecting Output to a File  command > file - Direct standard output of command to file  command >> file - Append standard output of command to file  command < file - Send file as input to command  command 2> file - Redirect error messages from command to file  command 2>> file - Append error messages from command to file
  • 6. Redirecting Output to a File Examples  This command generates output and errors when run as non- root:  $ find /etc -name passwd  Operators can be used to store output and errors:  $ find /etc -name passwd > find.out  $ find /etc -name passwd 2> /dev/null  $ find /etc -name passwd > find.out 2> find.err
  • 7. Redirecting STDOUT to a Program (Piping)  Pipes (the | character) can connect commands: command1 | command2  Sends STDOUT of command1 to STDIN of command2 instead of the screen.  STDERR is not forwarded across pipes  Used to combine the functionality of multiple tools command1 | command2 | command3... etc
  • 8. Redirecting STDOUT to a Program Examples  less: View input one page at a time: $ ls -l /etc | less Input can be searched with /  mail: Send input via email: $ echo "test email" | mail -s "test" student
  • 9. Combining Output and Errors  Some operators affect both STDOUT and STDERR  &>: Redirects all output: $ find /etc -name passwd &> find.all  2>&1: Redirects STDERR to STDOUT Useful for sending all output through a pipe $ find /etc -name passwd 2>&1 | less  (): Combines STDOUTs of multiple programs $ ( cal 2007 ; cal 2008 ) | less
  • 10. Redirecting to Multiple Targets (tee)  $ command1 | tee filename | command2  Stores STDOUT of command1 in filename, then pipes to command2  Uses:  Troubleshooting complex pipelines  Simultaneous viewing and logging of output ls -lR /etc | tee stage1.out | sort | tee stage2.out | uniq -c | tee stage3.out | sort -r | tee stage4.out | less
  • 11. Redirecting STDIN from a File  Redirect standard input with <  Some commands can accept data redirected to STDIN from a file: $ tr 'A-Z' 'a-z' < .bash_profile  This command will translate the uppercase characters in .bash_profile to lowercase  Equivalent to: $ cat .bash_profile | tr 'A-Z' 'a-z'
  • 12. Sending Multiple Lines to STDIN  Redirect multiple lines from keyboard to STDIN with <<WORD  All text until WORD is sent to STDIN  Sometimes called a heretext $ mail -s "Please see" student@localhost <<END > Hi all, >I’m Tam > END
  • 13. Scripting: for loops Performs actions on each member of a set of values Example: for NAME in joe jane julie do ADDRESS="$NAME@example.com" MESSAGE='Projects are due today!' echo $MESSAGE | mail -s Reminder $ADDRESS done
  • 14. Scripting: for loops continued  Can also use command-output and file lists:  for num in $(seq 1 10) • Assigns 1-10 to $num • seq X Y prints the numbers X through Y  for file in *.txt • Assigns names of text files to $file
  • 15. example #!/bin/bash # alive2.sh # Checks to see if hosts 192.168.0.1-192.168.0.20 are alive # Iterate through IP addresses for n in {1..20}; do host=192.168.0.$n ping -c2 $host &> /dev/null if [ $? = 0 ]; then echo "$host is UP" else echo "$host is DOWN" fi done