Difference between revisions of "Tutorial5: Redirection"

From CDOT Wiki
Jump to: navigation, search
(Additional File Manipulation Commands)
(Additional File Manipulation Commands)
Line 63: Line 63:
 
There are some additional regular file manipulation commands that you can use with redirection (in addition to the other regular file manipulation commands introduced in week 2). These commands are displayed in the table below:
 
There are some additional regular file manipulation commands that you can use with redirection (in addition to the other regular file manipulation commands introduced in week 2). These commands are displayed in the table below:
  
<table cellpadding="5"><tr><th style="border-bottom: 1px solid black;">Linux Command</th><th style="border-bottom: 1px solid black;">Purpose</th></tr><tr><td>'''touch'''</td><td>Create empty file(s) / Updates Existing File's Date/Time Stamp</td></tr><tr><td>'''cat'''</td><td>Display text file's contents without editing (small files)</td></tr><tr><td>'''more , less'''</td><td>Display / Navigate within large text files without editing</td></tr><tr><td>'''cp'''</td><td>Copy text file(s)</td></tr><tr><td>'''mv'''</td><td>Move / Rename text files</td></tr><tr><td>'''rm'''</td><td>Remove text file(s)</td></tr><tr valign="top"><td>'''sort'''</td><td>Sorts (rearranges) order of file contents when displayed. Content is sorted alphabetically by default. The '''-n'''''Italic text'' option sorts numerically, '''-r''' performs a reverse sort</td></tr><tr valign="top"><td>'''head''' , '''tail'''</td><td>Displays the first / last 10 lines of a text file by default. An option using a value will display the number of lines (e.g. head -5 filename will display first 5 lines, tail -5 filename will display last 5 lines).</td></tr><tr valign="top"><td>'''grep'''</td><td>Displays file contents that match a pattern</td></tr><tr valign="top"><td>'''uniq'''</td><td>Displays identical consecutive lines only once</td></tr><tr valign="top"><td>'''diff''' file1 file2</td><td>Displays differences between 2 files</td></tr><tr><td>'''file'''</td><td>Gives info about the contents of the file (e.g. file with no extention)</td></tr><tr valign="top"><td>'''find'''</td><td>To find files matching specified characteristics:<table><tr valign="top"><td width="20%">'''find . -name "file*"'''</td><td>List pathname of any filenames beginning with "file",<br>from the current directory and any subdirectories</td></tr><tr valign="top"><td>'''find . -size +50k'''</td><td>List pathname of any files larger than 50 kb, from the current directory and any subdirectories</td></tr><tr valign="top"><td>'''find . -mmin -5''' </td><td>List files modified less than 5 minutes ago</td></tr><tr> valign="top"><td>'''find -P .'''</td><td>Lists file pathnames in the current directory</td></tr></table></td></tr></table>
+
<table cellpadding="5"><tr><th style="border-bottom: 1px solid black;">Linux Command</th><th style="border-bottom: 1px solid black;">Purpose</th></tr><tr><td>'''cut'''</td><td>x</td></tr><tr><td>'''tr'''</td><td>x</td></tr><tr><td>'''wc'''</td><td>x</td></tr></table></td></tr></table>
  
 
===Piping (Using Pipes)===
 
===Piping (Using Pipes)===

Revision as of 13:16, 23 January 2020

REDIRECTION: STANDARD INPUT / STANDARD OUTPUT / STANDARD ERROR


Main Objectives of this Practice Tutorial

  • x
  • x
  • x
  • x

Tutorial Reference Material

Course Notes
Linux Command/Shortcut Reference
YouTube Videos
Course Notes:


Redirection
  • Standard Input (stdin)
  • Standard Output (stdout)
  • Standard Error (stderr)
  • Piping (pipes)

Multiple Commands

  • Semicolon
  • Grouping ( )


Redirection Filters
  • head
  • tail
  • sort
  • grep
  • cut
  • tr
  • wc
Brauer Instructional Videos:

KEY CONCEPTS

Redirection (Standard Input, Standard Output, Standard Error)

... standard streams are preconnected input and output communication channels between a computer program and its environment when it begins execution. The three input/output (I/O) connections are called standard input (stdin), standard output (stdout) and standard error (stderr). Originally I/O happened via a physically connected system console (input via keyboard, output via monitor), but standard streams abstract this. When a command is executed via an interactive shell, the streams are typically connected to the text terminal on which the shell is running, but can be changed with redirection or a pipeline.

Reference: https://en.wikipedia.org/wiki/Standard_streams


Additional File Manipulation Commands

There are some additional regular file manipulation commands that you can use with redirection (in addition to the other regular file manipulation commands introduced in week 2). These commands are displayed in the table below:

Linux CommandPurpose
cutx
trx
wcx
</td></tr></table>

Piping (Using Pipes)

x


Multiple Commands Using Semicolon ; / Grouping Commands ( )

x

INVESTIGATION 1: BASICS OF REDIRECTION


In this section, you will learn how to ...



Perform the Following Steps:

  1. x

In the next investigation, you will ...

INVESTIGATION 2: REDIRECTION USING PIPES

In this section, you will learn how to ...


Perform the Following Steps:

  1. x

In the next investigation, you will ...

INVESTIGATION 3: MULTIPLE COMMANDS / COMMAND GROUPING

In this section, you will learn how to ...


Perform the Following Steps:

  1. x

LINUX PRACTICE QUESTIONS

The purpose of this section is to obtain extra practice to help with quizzes, your midterm, and your final exam.

Here is a link to the MS Word Document of ALL of the questions displayed below but with extra room to answer on the document to simulate a quiz:

https://ict.senecacollege.ca/~murray.saul/uli101/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:

  1. x
  2. x
  3. x
  4. x
  5. x
  6. x
  7. x
  8. x
  9. Create a table listing each Linux command, useful options that were mentioned in the online assignment #1 and command purpose for the following Linux commands: cut , tr , wc