Changes

Jump to: navigation, search

Tutorial5: Redirection

428 bytes added, 20:35, 4 September 2023
no edit summary
{{Admon/caution|DO NOT USE THIS VERSION OF THE LAB. This page will no longer be updated.|'''New version here:''' https://seneca-ictoer.github.io/ULI101/A-Tutorials/tutorial5<br />'''Andrew's students please go here:''' http://wiki.littlesvr.ca/wiki/OPS145_Lab_5}}
=REDIRECTION: STANDARD INPUT / STANDARD OUTPUT / STANDARD ERROR=
<br>
|- valign="top" style="padding-left:15px;"
|colspan="2" |'''Slides:'''<ul><li>Week 5 Lecture 1 Notes:<br> [[Mediahttps://wiki.cdot.senecacollege.ca/uli101/slides/ULI101-Week55.1.pdf | PDF]] | [https://matrixwiki.cdot.senecacollege.ca/~chris.johnsonuli101/ULI101slides/ULI101-Week55.1.pptx PPTX]<br/li><li>Week 1 5 Lecture 2 Notes:<br> [[Mediahttps://wiki.cdot.senecacollege.ca/uli101/slides/ULI101-Week55.2.pdf | PDF]] | [https://matrixwiki.cdot.senecacollege.ca/~jason.carmanuli101/slides/ULI101-Week55.2.pptx PPTX] <br></li></ul>
=INVESTIGATION 1: BASICS OF REDIRECTION=
<span style="color:red;">'''ATTENTION''': Effective '''May 9, 2022''' - this This online tutorial will be required to be completed by '''Friday in week 6 by midnight'''<br>to obtain a grade of '''2%''' towards this course</span><br><br>
In this investigation, you will learn how to redirect '''standard input''', '''standard output''' and '''standard error''' when issuing Unix / Linux commands.
# Press <span style="color:blue;font-weight:bold;font-family:courier;">ctrl-d</span> to exit the command.<br><br>
# Issue the '''cat''' command to view the contents of the file: '''output3.txt'''<br><br>
# Issue the following Linux command: <span style="color:blue;font-weight:bold;font-family:courier;">cp ~murrayjason.saulcarman/uli101/cars .</span><br><br>
# Issue the '''cat''' command to view the contents of the '''cars''' file.<br><br>
# Issue the following Linux command: <span style="color:blue;font-weight:bold;font-family:courier;">cut -c1-10 cars</span><br><br>What did this command do?<br><br>
# Issue a Linux command to view the contents of the file called '''output.txt'''<br><br>What does ''grouping'' do when issuing multiple Linux commands (separated by a semi-colon ";") that uses redirection?<br><br>
# Issue the following Linux pipeline command (using \ at the end of most lines):<br><span style="color:blue;font-family:courier;font-weight:bold">echo "This will be split over multiple \<br>lines. Note that the shell will realize \<br>that a pipe requires another command, so \<br>it will automatically go to the next line" |tr '[a-z]' '[A-Z]'</span><br><br>Did the command work? What is the purpose of issuing a Linux command in this way?<br><br>
# After you complete Complete the Review Questions sections to get additional practice, then work on your '''online assignment 2'''<br>and complete '''section3''' labelled: '''Redirection and Pipes'''.
<br><br>
simulate a quiz:
https://ictwiki.cdot.senecacollege.ca/~murray.saululi101/uli101files/uli101_week5_practice.docx
Your instructor may take-up these questions during class. It is up to the student to attend classes in order to obtain the answers to the following questions. Your instructor will NOT provide these answers in any other form (eg. e-mail, etc).
'''Review Questions:'''
# Write a single Linux command to provide a detailed listing of all files in the '''/binetc''' directory, sending the output to a file called listing.txt in the “'''projects'''” directory (append output to existing file and use a relative pathname)
# Write a single Linux command to redirect the stderr from the command:<br>'''cat a.txt b.txt c.txt''' to a file called '''error.txt''' contained in the “'''assignments'''” directory. (overwrite previous file’s contents and use only relative pathnames)
# Write a single Linux command: '''cat ~/a.txt ~/b.txt ~/c.txt''' and redirect stdout to a file called “good.txt” to the “tests” directory and stderr to a file called “'''bad.txt'''” to the “'''tests'''” directory. (overwrite previous contents for both files and use only relative-to-home pathnames).
# Write a single Linux '''pipeline command''' to display only the first 10 characters of each filename contained in your current directory. Also, there is will be a lot of output, so also pause at each screenful so you can navigate throughout the display contents. Use a relative pathname.
# Create a '''table''' listing each Linux command, useful options that were mentioned in this tutorial for the following Linux commands: '''cut''' , '''tr''' , '''wc''' , and '''tee'''.
 
 
 
_________________________________________________________________________________
 
Author: Murray Saul
 
License: LGPL version 3
Link: https://www.gnu.org/licenses/lgpl.html
 
_________________________________________________________________________________
 
[[Category:ULI101]]

Navigation menu