SlideShare une entreprise Scribd logo
1  sur  12
Télécharger pour lire hors ligne
Laboratory Experiment IV




 PRINTING AND METACHARACTERS
 by Alex Shaw III




 Unedited Version




May 3, 2005
TABLE OF CONTENTS

Introduction                   ii

Laboratory Sheets             iii
Procedures                    iii

Data Sheets                   1
Results                        1
   Part I                      1
   Part II                     2

Analysis                      4
Explanations                   4
   Part I                      4
   Part II                     4
   Metacharacters              5
Discoveries                    6
   Part II                     6
New Commands                   7
References                     8




Printing and Metacharacters     i
INTRODUCTION

                              This experiment involves printing and metacharacters.
                              The first part focuses on printing files using various
                              techniques. Redirections, basic metacharacters, and
                              appending to files are the focal point in the second part of
                              the experiment.

                              The main commands used in this experiment are cat, lpr,
                              and pr. Other commands, like cd and ls, which facilitate
                              file and directory navigation, assist in the performance of
                              tasks.




Printing and Metacharacters                                                              ii
1
                                                                             LABORATORY SHEETS
LABORATORY EXPERIMENT IV


Procedures
The procedures (Sheet 1-1 and Sheet 1-2) below provide the steps performed during this experiment.




Sheet 1-1 Part I of the laboratory procedures—focuses on printing and      Sheet 1-2 Part II of the laboratory procedures—focuses on basic
utilizing redirection and piping to provide output to a printer or file.   metacharacters, listing and viewing files, and appending to files.




Printing and Metacharacters                                                                                                                     iii
2
                                                                                                            DATA SHEETS
LABORATORY EXPERIMENT IV


                                                                            Results
                                                                            This section provides the results for each task. Some
                                                                            tasks require in-depth explanations, while others present
                                                                            simple results.
                                                                            Part I
Output 2-1 Contents of prtfile1.
                                                                            Task 1
                                                                            Logged into home directory.
                                                                            Task 2
                                                                            Created prtfile1 (Output 2-1) in home directory.
                                                                            Task 3
Output 2-2 Contents of prtfile2. This file is actually takes up an entire
                                                                            The pr prtfile1 command seems to display the contents
screen because the pr command generated it, which is discussed in the       of the prtfile1 to the standard output (screen), which
Analysis section.
                                                                            actually scrolls off the screen.

This file is created for Experiment 4.                                      Task 4
It focuses on printing and metacharacters.                                  The pr prtfile1 > prtfile2 displays no visible results, but
I guess this file should contain more                                       produces prtfile2 (Output 2-2).
than three lines to make
                                                                            Task 5
Output 2-3 This is a printout of prtfile1 from Task 7.
                                                                            The pr prtfile1 | more command pipes the results of
                                                                            pr prtfile1 to the more command, which in turn displays
This file is created for Experiment 4.                                      the results one screenful at a time.
It focuses on printing and metacharacters.
I guess this file should contain more                                       Task 6
than three lines to make                                                    Results of pr prtfile1, pr prtfile1 > prtfile2, and
Output 2-4 This is a printout of prtfile1 from Task 8.                      pr prtfile1 | more are analyzed in the Analysis section.

2005-04-05 19:21                     prtfile1                     Page 1
                                                                            Task 7
                                                                            The cat prtfile1 | lpr -Ppr2191 pipes the results of
This file is created for Experiment 4.                                      cat prtfile1 to lpr -Ppr219, which prints the contents of
It focuses on printing and metacharacters.
I guess this file should contain more                                       prtfile1 to printer 219 (Output 2-3).
than three lines to make

Output 2-5 This is a printout of prtfile1 from Task 9.                      Task 8
                                                                            The lpr -Ppr219 prtfile1 prints prtfile1 to printer 219
                                                                            (Output 2-4).
                                                                            Task 9
                                                                            The pr prtfile1 | lpr command pipes the results of pr prtfile1
                                                                            to lpr, which prints those results to the default printer
                                                                            (Output 2-5).
                                                                                                                          continue on next page…



                                                                            1
                                                                                Printer 219 is located in Lehman College. Your printer may have a different
                                                                                name or location.



Printing and Metacharacters                                                                                                                              1
Data Sheets



                                                                            Task 10
                                                                            The pr prtfile1 > lpr command redirects the output of
                                                                            pr prtfile1 to the lpr file.

                                                                            Task 11
                                                                            The difference between pr prtfile1 | lpr and
                                                                            pr prtfile1 > lpr are discussed in the Analysis section.


                                                                            Part II

                                                                            Task 1
                                                                            The cd ~ changes to the home directory.

Output 2-6 Contents of list.files. This file was generated from the         Task 2
ls > list.files command.                                                    The ls > list.files command displays no results to the screen.

                                                                            Task 3
                                                                            The cat list.files command displays the contents of
                                                                            list.files (Output 2-6) to the screen or standard output.

Output 2-7 Results of the ls c* command, performed in the /bin directory.
                                                                            Task 4
                                                                            Issuing ls > list.files redirects the output of ls to the
                                                                            list.files file.
                                                                            The "greater than" (>) sign is presented in Task 2 is
                                                                            discussed in the Analysis section.

                                                                            Task 5
                                                                            The cd /bin command changed the current director to /bin.

                                                                            Task 6
                                                                            Issuing ls c* displays a listing of all the files in the
                                                                            current directory (/bin) starting with 'c' (Output 2-7).

                                                                            Task 7
                                                                            See the Analysis section for a discussion on the asterisk (*).

                                                                            Task 8
                                                                            The cd $HOME command returns to the home directory.

                                                                            Task 9
                                                                            The ls /bin/c* >> list.files command displays no results
                                                                            to the screen.
Output 2-8 Contents of the list.files after issuing the
ls /bin/c* >> list.files command.                                           Task 10
                                                                            The cat list.files command displays the contents of
                                                                            list.files (Output 2-8) to the screen.
                                                                                                                 continue on next page…




Printing and Metacharacters                                                                                                              2
Data Sheets




                                                          Task 11
                                                          A discussion of what happened with list.files after task 2
                                                          and task 9 is in the Analysis section.

                                                          Task 12
                                                          The ls /bin/c* > list.files command displays no results on
                                                          the screen.

                                                          Task 13
                                                          Issuing ls /bin/c* > list.files redirects output from
Output 2-9 Contents of the list.files after issuing the   ls /bin/c* the list.files (Output 2-9) file. More discussion
ls /bin/c* > list.files command.
                                                          on this task is in the Analysis section.

                                                          Task 14
                                                          Along with the metacharacters presented in this
                                                          experiment, the brackets "[ ]" metacharacter is also
                                                          discussed in the Analysis section.




Printing and Metacharacters                                                                                            3
3
                                                                                                ANALYSIS
LABORATORY EXPERIMENT IV


                                                              Explanations
                                                              Part I

                                                              Task 6
                                                              The pr prtfile1 command displays the contents of prtfile1
                                                              to the screen one page at a time. Even if there is only one
Output 3-1 Contents of prtfile1.
                                                              line of text, an entire page is still display; therefore, the
                                                              screen may scroll beyond the contents of the file.

                                                              The pr prtfile1 > prtfile2 redirects the output of
                                                              pr prtfile1 to the prtfile2 file. That does not mean
                                                              prtfile1 and prtfile2 will be identical; the pr prtfile1
                                                              command adds a header to the prtfile1 file. You can see
Output 3-2 Contents of prtfile2.                              the difference in Output 3-1 and Output 3-2.

                                                              The pr prtfile1 | more command pipes the results of
                                                              pr prtfile1 to the more command, which allows the user
                                                              to view the file one screenful at a time. It fixes the result
Output 3-3 Results of the ls command in the home directory.
                                                              encountered with the pr prtfile1 command.

                                                              Task 11
                                                              The pr prtfile1 | lpr command pipes the results of
                                                              pr prtfile1 to the lpr command, which prints those
                                                              results; and pr prtfile1 > lpr redirects the output of
                                                              pr prtfile1 to the lpr file.

                                                              Part II
                                                              Task 4
                                                              Issuing ls > list.files redirects the output of the ls
                                                              command to the list.files file. In previous experiments,
                                                              output redirection created a file identical to the
                                                              command's result.
Output 3-4 Contents of list.files.
                                                              However, list.files displays the directory structure in a
                                                              manner similar to the way ls -l would. ls alone display
                                                              the directory structure horizontally.

                                                              See Output 3-3 and Output 3-4 for the difference
                                                              between ls and list.files.

                                                              The '>' symbol is discussed on page 5.
                                                                                                 continue on next page…




Printing and Metacharacters                                                                                               4
Analysis




                                                          Task 7
                                                          The '*' symbol is discussed in Metacharacters.

                                                          Task 11
                                                          After issuing the ls /bin/c* >> list.files command,
                                                          list.files is concatenated with the old list.files, as shown in
                                                          Output 3-6.

                                                          The '>>' symbol is discussed on page 5.

                                                          Task 13
                                                          Issuing a command with output redirection to an existing
                                                          file causing the file to be replaced with the results of the
                                                          command. Therefore, ls /bin/c* > list.files replaces
Output 3-5 Contents of list.files before issuing the      list.files with the results of ls /bin/c*.
ls /bin/c* >> list.files command.


                                                          Metacharacters
                                                          The *, >, and >>, and | are metacharacters used in this
                                                          experiment. Their purpose is in the table below:

                                                          Metacharacter Purpose
                                                          *                        Matches zero or more characters
                                                          >                        Output redirection
                                                          >>                       Redirect by appendage
                                                          |                        Pipe between commands
                                                          []1                      Insert wildcards




Output 3-6 Contents of the list.files after issuing the
ls /bin/c* >> list.files command.




                                                          1
                                                              Not used in this experiment.



Printing and Metacharacters                                                                                              5
Analysis




                              Discoveries

                              Part II

                              Task 2
                              Issuing the ls command lists the directory contents
                              horizontally; however, when redirected to a file, it places
                              the contents of a directory line-by-line (vertically).




Printing and Metacharacters                                                             6
Analysis




                              New Commands
                              Below is a list of new commands used in this experiment:

                              Command           Purpose
                                  1
                              pr                Format files page-by-page and display to
                                                standard output or printer.




                              1
                                  For a complete syntax of the pr command type pr --help or man pr at the
                                  LINUX shell prompt.



Printing and Metacharacters                                                                                 7
Analysis




                              References
                              1.   Sarwar, Syed Mansoor, Robert Koretsky, Syed
                                   Aqeel Sarwar. Linux: The Textbook. Boston:
                                   Addison Wesley Longman Inc., 2002.




Printing and Metacharacters                                                        8

Contenu connexe

En vedette

En vedette (9)

Overview of T-Trendset 1.1
Overview of T-Trendset 1.1Overview of T-Trendset 1.1
Overview of T-Trendset 1.1
 
Using Google Analytics in T-Trendset 1.1
Using Google Analytics in T-Trendset 1.1Using Google Analytics in T-Trendset 1.1
Using Google Analytics in T-Trendset 1.1
 
Input and Output Control
Input and Output ControlInput and Output Control
Input and Output Control
 
Tutorial—In-cell Dropdown List with Challenge
Tutorial—In-cell Dropdown List with ChallengeTutorial—In-cell Dropdown List with Challenge
Tutorial—In-cell Dropdown List with Challenge
 
Dynamic Chart Switcher
Dynamic Chart SwitcherDynamic Chart Switcher
Dynamic Chart Switcher
 
Unix interview questions
Unix interview questionsUnix interview questions
Unix interview questions
 
The Elevator
The ElevatorThe Elevator
The Elevator
 
Vi And Linux Environment
Vi And Linux EnvironmentVi And Linux Environment
Vi And Linux Environment
 
Linux Directory Structure
Linux Directory StructureLinux Directory Structure
Linux Directory Structure
 

Similaire à Printing and Metacharacters

Shell Scripting With Arguments
Shell Scripting With ArgumentsShell Scripting With Arguments
Shell Scripting With Arguments
Alex Shaw III
 
Input And Output Control
Input And Output ControlInput And Output Control
Input And Output Control
Alex Shaw III
 
fileop report
fileop reportfileop report
fileop report
Jason Lu
 
Migration from Firebird 1.5 to Firebird 2.5
Migration from Firebird 1.5 to Firebird 2.5Migration from Firebird 1.5 to Firebird 2.5
Migration from Firebird 1.5 to Firebird 2.5
Mind The Firebird
 
Chapter 02 modified
Chapter 02 modifiedChapter 02 modified
Chapter 02 modified
Jugal Doshi
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
mckennadglyn
 
Python and Pytorch tutorial and walkthrough
Python and Pytorch tutorial and walkthroughPython and Pytorch tutorial and walkthrough
Python and Pytorch tutorial and walkthrough
gabriellekuruvilla
 

Similaire à Printing and Metacharacters (20)

Shell Scripting With Arguments
Shell Scripting With ArgumentsShell Scripting With Arguments
Shell Scripting With Arguments
 
Input And Output Control
Input And Output ControlInput And Output Control
Input And Output Control
 
11_UNIX_Processes_Including_Select.ppt
11_UNIX_Processes_Including_Select.ppt11_UNIX_Processes_Including_Select.ppt
11_UNIX_Processes_Including_Select.ppt
 
20051019 automating regression testing for evolving gui software
20051019 automating regression testing for evolving gui software20051019 automating regression testing for evolving gui software
20051019 automating regression testing for evolving gui software
 
CrashCourse: Python with DataCamp and Jupyter for Beginners
CrashCourse: Python with DataCamp and Jupyter for BeginnersCrashCourse: Python with DataCamp and Jupyter for Beginners
CrashCourse: Python with DataCamp and Jupyter for Beginners
 
fileop report
fileop reportfileop report
fileop report
 
Migration from Firebird 1.5 to Firebird 2.5
Migration from Firebird 1.5 to Firebird 2.5Migration from Firebird 1.5 to Firebird 2.5
Migration from Firebird 1.5 to Firebird 2.5
 
PuppetConf 2016: Getting to the Latest Puppet – Nate McCurdy & Elizabeth Witt...
PuppetConf 2016: Getting to the Latest Puppet – Nate McCurdy & Elizabeth Witt...PuppetConf 2016: Getting to the Latest Puppet – Nate McCurdy & Elizabeth Witt...
PuppetConf 2016: Getting to the Latest Puppet – Nate McCurdy & Elizabeth Witt...
 
Chapter 02 modified
Chapter 02 modifiedChapter 02 modified
Chapter 02 modified
 
Tackling repetitive tasks with serial or parallel programming in R
Tackling repetitive tasks with serial or parallel programming in RTackling repetitive tasks with serial or parallel programming in R
Tackling repetitive tasks with serial or parallel programming in R
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Unit 7
Unit 7Unit 7
Unit 7
 
The Ring programming language version 1.6 book - Part 8 of 189
The Ring programming language version 1.6 book - Part 8 of 189The Ring programming language version 1.6 book - Part 8 of 189
The Ring programming language version 1.6 book - Part 8 of 189
 
Lab3 s2
Lab3 s2Lab3 s2
Lab3 s2
 
sphinx demo
sphinx demosphinx demo
sphinx demo
 
A Feature-Complete Petri Net A Feature-Complete Petri Net Semantics for WS-BP...
A Feature-Complete Petri Net A Feature-Complete Petri Net Semantics for WS-BP...A Feature-Complete Petri Net A Feature-Complete Petri Net Semantics for WS-BP...
A Feature-Complete Petri Net A Feature-Complete Petri Net Semantics for WS-BP...
 
Python and Pytorch tutorial and walkthrough
Python and Pytorch tutorial and walkthroughPython and Pytorch tutorial and walkthrough
Python and Pytorch tutorial and walkthrough
 
Process
ProcessProcess
Process
 
Using SWIG to Control, Prototype, and Debug C Programs with Python
Using SWIG to Control, Prototype, and Debug C Programs with PythonUsing SWIG to Control, Prototype, and Debug C Programs with Python
Using SWIG to Control, Prototype, and Debug C Programs with Python
 

Dernier

unwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabi
unwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabiunwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabi
unwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabi
Abortion pills in Kuwait Cytotec pills in Kuwait
 
Insurers' journeys to build a mastery in the IoT usage
Insurers' journeys to build a mastery in the IoT usageInsurers' journeys to build a mastery in the IoT usage
Insurers' journeys to build a mastery in the IoT usage
Matteo Carbone
 
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...
lizamodels9
 
Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...
Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...
Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...
Dipal Arora
 
Mifty kit IN Salmiya (+918133066128) Abortion pills IN Salmiyah Cytotec pills
Mifty kit IN Salmiya (+918133066128) Abortion pills IN Salmiyah Cytotec pillsMifty kit IN Salmiya (+918133066128) Abortion pills IN Salmiyah Cytotec pills
Mifty kit IN Salmiya (+918133066128) Abortion pills IN Salmiyah Cytotec pills
Abortion pills in Kuwait Cytotec pills in Kuwait
 
Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...
Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...
Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...
lizamodels9
 

Dernier (20)

👉Chandigarh Call Girls 👉9878799926👉Just Call👉Chandigarh Call Girl In Chandiga...
👉Chandigarh Call Girls 👉9878799926👉Just Call👉Chandigarh Call Girl In Chandiga...👉Chandigarh Call Girls 👉9878799926👉Just Call👉Chandigarh Call Girl In Chandiga...
👉Chandigarh Call Girls 👉9878799926👉Just Call👉Chandigarh Call Girl In Chandiga...
 
unwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabi
unwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabiunwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabi
unwanted pregnancy Kit [+918133066128] Abortion Pills IN Dubai UAE Abudhabi
 
Insurers' journeys to build a mastery in the IoT usage
Insurers' journeys to build a mastery in the IoT usageInsurers' journeys to build a mastery in the IoT usage
Insurers' journeys to build a mastery in the IoT usage
 
The Coffee Bean & Tea Leaf(CBTL), Business strategy case study
The Coffee Bean & Tea Leaf(CBTL), Business strategy case studyThe Coffee Bean & Tea Leaf(CBTL), Business strategy case study
The Coffee Bean & Tea Leaf(CBTL), Business strategy case study
 
Cracking the Cultural Competence Code.pptx
Cracking the Cultural Competence Code.pptxCracking the Cultural Competence Code.pptx
Cracking the Cultural Competence Code.pptx
 
Call Girls Pune Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Pune Just Call 9907093804 Top Class Call Girl Service AvailableCall Girls Pune Just Call 9907093804 Top Class Call Girl Service Available
Call Girls Pune Just Call 9907093804 Top Class Call Girl Service Available
 
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best ServicesMysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
Mysore Call Girls 8617370543 WhatsApp Number 24x7 Best Services
 
Monthly Social Media Update April 2024 pptx.pptx
Monthly Social Media Update April 2024 pptx.pptxMonthly Social Media Update April 2024 pptx.pptx
Monthly Social Media Update April 2024 pptx.pptx
 
Monte Carlo simulation : Simulation using MCSM
Monte Carlo simulation : Simulation using MCSMMonte Carlo simulation : Simulation using MCSM
Monte Carlo simulation : Simulation using MCSM
 
RSA Conference Exhibitor List 2024 - Exhibitors Data
RSA Conference Exhibitor List 2024 - Exhibitors DataRSA Conference Exhibitor List 2024 - Exhibitors Data
RSA Conference Exhibitor List 2024 - Exhibitors Data
 
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...
Russian Call Girls In Gurgaon ❤️8448577510 ⊹Best Escorts Service In 24/7 Delh...
 
A DAY IN THE LIFE OF A SALESMAN / WOMAN
A DAY IN THE LIFE OF A  SALESMAN / WOMANA DAY IN THE LIFE OF A  SALESMAN / WOMAN
A DAY IN THE LIFE OF A SALESMAN / WOMAN
 
John Halpern sued for sexual assault.pdf
John Halpern sued for sexual assault.pdfJohn Halpern sued for sexual assault.pdf
John Halpern sued for sexual assault.pdf
 
Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...
Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...
Call Girls Navi Mumbai Just Call 9907093804 Top Class Call Girl Service Avail...
 
Mifty kit IN Salmiya (+918133066128) Abortion pills IN Salmiyah Cytotec pills
Mifty kit IN Salmiya (+918133066128) Abortion pills IN Salmiyah Cytotec pillsMifty kit IN Salmiya (+918133066128) Abortion pills IN Salmiyah Cytotec pills
Mifty kit IN Salmiya (+918133066128) Abortion pills IN Salmiyah Cytotec pills
 
Boost the utilization of your HCL environment by reevaluating use cases and f...
Boost the utilization of your HCL environment by reevaluating use cases and f...Boost the utilization of your HCL environment by reevaluating use cases and f...
Boost the utilization of your HCL environment by reevaluating use cases and f...
 
Organizational Transformation Lead with Culture
Organizational Transformation Lead with CultureOrganizational Transformation Lead with Culture
Organizational Transformation Lead with Culture
 
Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...
Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...
Call Girls In DLf Gurgaon ➥99902@11544 ( Best price)100% Genuine Escort In 24...
 
VVVIP Call Girls In Greater Kailash ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...
VVVIP Call Girls In Greater Kailash ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...VVVIP Call Girls In Greater Kailash ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...
VVVIP Call Girls In Greater Kailash ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...
 
How to Get Started in Social Media for Art League City
How to Get Started in Social Media for Art League CityHow to Get Started in Social Media for Art League City
How to Get Started in Social Media for Art League City
 

Printing and Metacharacters

  • 1. Laboratory Experiment IV PRINTING AND METACHARACTERS by Alex Shaw III Unedited Version May 3, 2005
  • 2. TABLE OF CONTENTS Introduction ii Laboratory Sheets iii Procedures iii Data Sheets 1 Results 1 Part I 1 Part II 2 Analysis 4 Explanations 4 Part I 4 Part II 4 Metacharacters 5 Discoveries 6 Part II 6 New Commands 7 References 8 Printing and Metacharacters i
  • 3. INTRODUCTION This experiment involves printing and metacharacters. The first part focuses on printing files using various techniques. Redirections, basic metacharacters, and appending to files are the focal point in the second part of the experiment. The main commands used in this experiment are cat, lpr, and pr. Other commands, like cd and ls, which facilitate file and directory navigation, assist in the performance of tasks. Printing and Metacharacters ii
  • 4. 1 LABORATORY SHEETS LABORATORY EXPERIMENT IV Procedures The procedures (Sheet 1-1 and Sheet 1-2) below provide the steps performed during this experiment. Sheet 1-1 Part I of the laboratory procedures—focuses on printing and Sheet 1-2 Part II of the laboratory procedures—focuses on basic utilizing redirection and piping to provide output to a printer or file. metacharacters, listing and viewing files, and appending to files. Printing and Metacharacters iii
  • 5. 2 DATA SHEETS LABORATORY EXPERIMENT IV Results This section provides the results for each task. Some tasks require in-depth explanations, while others present simple results. Part I Output 2-1 Contents of prtfile1. Task 1 Logged into home directory. Task 2 Created prtfile1 (Output 2-1) in home directory. Task 3 Output 2-2 Contents of prtfile2. This file is actually takes up an entire The pr prtfile1 command seems to display the contents screen because the pr command generated it, which is discussed in the of the prtfile1 to the standard output (screen), which Analysis section. actually scrolls off the screen. This file is created for Experiment 4. Task 4 It focuses on printing and metacharacters. The pr prtfile1 > prtfile2 displays no visible results, but I guess this file should contain more produces prtfile2 (Output 2-2). than three lines to make Task 5 Output 2-3 This is a printout of prtfile1 from Task 7. The pr prtfile1 | more command pipes the results of pr prtfile1 to the more command, which in turn displays This file is created for Experiment 4. the results one screenful at a time. It focuses on printing and metacharacters. I guess this file should contain more Task 6 than three lines to make Results of pr prtfile1, pr prtfile1 > prtfile2, and Output 2-4 This is a printout of prtfile1 from Task 8. pr prtfile1 | more are analyzed in the Analysis section. 2005-04-05 19:21 prtfile1 Page 1 Task 7 The cat prtfile1 | lpr -Ppr2191 pipes the results of This file is created for Experiment 4. cat prtfile1 to lpr -Ppr219, which prints the contents of It focuses on printing and metacharacters. I guess this file should contain more prtfile1 to printer 219 (Output 2-3). than three lines to make Output 2-5 This is a printout of prtfile1 from Task 9. Task 8 The lpr -Ppr219 prtfile1 prints prtfile1 to printer 219 (Output 2-4). Task 9 The pr prtfile1 | lpr command pipes the results of pr prtfile1 to lpr, which prints those results to the default printer (Output 2-5). continue on next page… 1 Printer 219 is located in Lehman College. Your printer may have a different name or location. Printing and Metacharacters 1
  • 6. Data Sheets Task 10 The pr prtfile1 > lpr command redirects the output of pr prtfile1 to the lpr file. Task 11 The difference between pr prtfile1 | lpr and pr prtfile1 > lpr are discussed in the Analysis section. Part II Task 1 The cd ~ changes to the home directory. Output 2-6 Contents of list.files. This file was generated from the Task 2 ls > list.files command. The ls > list.files command displays no results to the screen. Task 3 The cat list.files command displays the contents of list.files (Output 2-6) to the screen or standard output. Output 2-7 Results of the ls c* command, performed in the /bin directory. Task 4 Issuing ls > list.files redirects the output of ls to the list.files file. The "greater than" (>) sign is presented in Task 2 is discussed in the Analysis section. Task 5 The cd /bin command changed the current director to /bin. Task 6 Issuing ls c* displays a listing of all the files in the current directory (/bin) starting with 'c' (Output 2-7). Task 7 See the Analysis section for a discussion on the asterisk (*). Task 8 The cd $HOME command returns to the home directory. Task 9 The ls /bin/c* >> list.files command displays no results to the screen. Output 2-8 Contents of the list.files after issuing the ls /bin/c* >> list.files command. Task 10 The cat list.files command displays the contents of list.files (Output 2-8) to the screen. continue on next page… Printing and Metacharacters 2
  • 7. Data Sheets Task 11 A discussion of what happened with list.files after task 2 and task 9 is in the Analysis section. Task 12 The ls /bin/c* > list.files command displays no results on the screen. Task 13 Issuing ls /bin/c* > list.files redirects output from Output 2-9 Contents of the list.files after issuing the ls /bin/c* the list.files (Output 2-9) file. More discussion ls /bin/c* > list.files command. on this task is in the Analysis section. Task 14 Along with the metacharacters presented in this experiment, the brackets "[ ]" metacharacter is also discussed in the Analysis section. Printing and Metacharacters 3
  • 8. 3 ANALYSIS LABORATORY EXPERIMENT IV Explanations Part I Task 6 The pr prtfile1 command displays the contents of prtfile1 to the screen one page at a time. Even if there is only one Output 3-1 Contents of prtfile1. line of text, an entire page is still display; therefore, the screen may scroll beyond the contents of the file. The pr prtfile1 > prtfile2 redirects the output of pr prtfile1 to the prtfile2 file. That does not mean prtfile1 and prtfile2 will be identical; the pr prtfile1 command adds a header to the prtfile1 file. You can see Output 3-2 Contents of prtfile2. the difference in Output 3-1 and Output 3-2. The pr prtfile1 | more command pipes the results of pr prtfile1 to the more command, which allows the user to view the file one screenful at a time. It fixes the result Output 3-3 Results of the ls command in the home directory. encountered with the pr prtfile1 command. Task 11 The pr prtfile1 | lpr command pipes the results of pr prtfile1 to the lpr command, which prints those results; and pr prtfile1 > lpr redirects the output of pr prtfile1 to the lpr file. Part II Task 4 Issuing ls > list.files redirects the output of the ls command to the list.files file. In previous experiments, output redirection created a file identical to the command's result. Output 3-4 Contents of list.files. However, list.files displays the directory structure in a manner similar to the way ls -l would. ls alone display the directory structure horizontally. See Output 3-3 and Output 3-4 for the difference between ls and list.files. The '>' symbol is discussed on page 5. continue on next page… Printing and Metacharacters 4
  • 9. Analysis Task 7 The '*' symbol is discussed in Metacharacters. Task 11 After issuing the ls /bin/c* >> list.files command, list.files is concatenated with the old list.files, as shown in Output 3-6. The '>>' symbol is discussed on page 5. Task 13 Issuing a command with output redirection to an existing file causing the file to be replaced with the results of the command. Therefore, ls /bin/c* > list.files replaces Output 3-5 Contents of list.files before issuing the list.files with the results of ls /bin/c*. ls /bin/c* >> list.files command. Metacharacters The *, >, and >>, and | are metacharacters used in this experiment. Their purpose is in the table below: Metacharacter Purpose * Matches zero or more characters > Output redirection >> Redirect by appendage | Pipe between commands []1 Insert wildcards Output 3-6 Contents of the list.files after issuing the ls /bin/c* >> list.files command. 1 Not used in this experiment. Printing and Metacharacters 5
  • 10. Analysis Discoveries Part II Task 2 Issuing the ls command lists the directory contents horizontally; however, when redirected to a file, it places the contents of a directory line-by-line (vertically). Printing and Metacharacters 6
  • 11. Analysis New Commands Below is a list of new commands used in this experiment: Command Purpose 1 pr Format files page-by-page and display to standard output or printer. 1 For a complete syntax of the pr command type pr --help or man pr at the LINUX shell prompt. Printing and Metacharacters 7
  • 12. Analysis References 1. Sarwar, Syed Mansoor, Robert Koretsky, Syed Aqeel Sarwar. Linux: The Textbook. Boston: Addison Wesley Longman Inc., 2002. Printing and Metacharacters 8