SlideShare a Scribd company logo
1 of 20
Managing Documents

Objectives
In this lesson, you will learn to:
 Identify the standard input, output, and error files

 Use input, output, and error redirection

 Identify the features and options of the grep, wc, cut,
  and tr filters

 Combine multiple commands by using Pipes

 Locate a file by using the find command

 Assign File Access Permissions (FAPs)


©NIIT                                   Linux/Lesson 2/Slide 1 of 20
Managing Documents

Standard Files
 Standard Input File
    The keyboard is referred to as the standard input
     file
     In Linux, all the open files, including the standard
      files, are assigned a number called the file
      descriptor. The file descriptor 0 is assigned to the
      standard input file
 Standard Output File
     The monitor is referred to as the standard output
      file
     The file descriptor 1 is assigned to the standard
      output file
©NIIT                                   Linux/Lesson 2/Slide 2 of 20
Managing Documents

Standard Files (contd)
 Standard Error File
    The monitor is also the standard error file
     The file descriptor 2 is assigned to the standard
      error file




©NIIT                                  Linux/Lesson 2/Slide 3 of 20
Managing Documents

Redirection
Redirection changes the assignments for the standard
input, output, and error
Input Redirection
    The following example illustrates the use of input
     redirection:

    $ cat  test1 Enter
Output Redirection
   The following example illustrates the use of output
    redirection:

    $ cat test1  test2

©NIIT                                  Linux/Lesson 2/Slide 4 of 20
Managing Documents

Redirection (contd.)
 Error Redirection
   The following example illustrates the use of error
   redirection:

    $ cat datafile 2 error-mesg Enter




©NIIT                                 Linux/Lesson 2/Slide 5 of 20
Managing Documents

Filters
A filter is a program that takes its input from the standard
input file, processes (or filters) it, and sends its output to
the standard output file
The grep Filter
   The grep filter searches a file for a particular pattern
   of characters and displays all the lines that contain
   that pattern. The pattern that is searched for is
   referred to as a regular expression
        grep regular_expression [filename]




©NIIT                                     Linux/Lesson 2/Slide 6 of 20
Managing Documents

Filters (contd.)
The grep Filter (contd.)
  Options of the grep Filter
        -n : This prints each line matching the pattern
         along with its line number
        -c : This prints only a count of the lines that
         match a pattern
        -v : This prints all the lines that do not match the
         pattern specified by the regular expression




©NIIT                                    Linux/Lesson 2/Slide 7 of 20
Managing Documents

Filters (contd.)
 The wc Filter
     The wc filter is used to count the number of lines,
      words, and characters in a disk file or in the
      standard input
        wc [-lwc] [filename/s ]
 The cut Filter
     The cut filter is useful when specific columns from
      the output of certain commands (such as ls, who)
      need to be extracted
        cut [options] [filename/s]


©NIIT                                   Linux/Lesson 2/Slide 8 of 20
Managing Documents

Filters (contd.)
 The tr Filter
     The tr filter can be used to translate one set of
      characters to another
    $ tr ':' ' '  /etc/passwd




©NIIT                                  Linux/Lesson 2/Slide 9 of 20
Managing Documents
Just a Minute…
        The details of various customers who have
        registered with Diaz Telecommunications are
        stored in the Customers file. The sample data of
        the file is as follows:
        000001,Angela,Smith,16223
        Radiance Court,Kansas
        City,Kansas
        000002,Barbara,Johnson,227
        Beach Ave.,Alexandria,Virginia
        000003,Betty,Williams,1 Tread
        Road,Dublin,Georgia



©NIIT                                  Linux/Lesson 2/Slide 10 of 20
Managing Documents
Just a Minute…(contd.)
     Write a command to find the number of people
      staying in the state of Kansas
     Write a command to display the complete details
      along with the line number in which the details are
      present for the customer Linda




©NIIT                                 Linux/Lesson 2/Slide 11 of 20
Managing Documents
Pipes
 The vertical bar (|) is the pipe character
 It indicates to the shell that the output of the command
  before ‘|’ is to be sent as input to the command after
  ‘|’
 The tee Command
     The tee command takes standard input and writes
      to standard output to file(s)
     If the file where data is to be written does not exist,
      the file is created
     If the file already exists, its contents are
      overwritten
    cat temp | tee temp1 temp2
©NIIT                                    Linux/Lesson 2/Slide 12 of 20
Managing Documents
Just a Minute…
        The details of various customers who have
        registered with Diaz Telecommunications are
        stored in the Customers file. Sample data from the
        file is as follows:
        000001,Angela,Smith,16223
        Radiance Court,Kansas
        City,Kansas
        000002,Barbara,Johnson,227
        Beach Ave.,Alexandria,Virginia
        000003,Betty,Williams,1 Tread
        Road,Dublin,Georgia



©NIIT                                  Linux/Lesson 2/Slide 13 of 20
Managing Documents
Just a Minute…(contd.)
        In the file, the field delimiter is ','. The various fields
        are CustomerCode, FirstName, LastName,
        Address, City, and State. Write a command to
        display only the FirstName and the LastName of
        the customers living in Georgia




©NIIT                                       Linux/Lesson 2/Slide 14 of 20
Managing Documents
Locating Files in Linux
 The find Command
    find [path] [expression]
     The find command is used to locate a file in a
     particular directory and in all its subdirectories. It is
     the most commonly used command for locating
     files and has various options for advanced
     searches




©NIIT                                    Linux/Lesson 2/Slide 15 of 20
Managing Documents

File Access Permissions (FAPs)
 File Access Permissions (FAPs) refer to the
  permissions associated with a file with respect to the
  following:
     The file owner
     The group owner
     Other users




©NIIT                                 Linux/Lesson 2/Slide 16 of 20
Managing Documents

Assigning Permissions to Files
 The chmod command
    chmod mode file/s
     The chmod command is used to change the
      permissions associated with a file or a directory.
     There are two modes for assigning the
      permissions:
    • Symbolic mode – the permissions and the type of
      users for whom the permission is to be granted are
      given in symbols.
    • Absolute mode – In this, a series of digits is used
      to represent the actual permissions.

©NIIT                                  Linux/Lesson 2/Slide 17 of 20
Managing Documents
Summary
In this lesson, you learned that:
 You can redirect input, output, and errors to a file
  other than the standard files by the file descriptors
  along with the redirection symbols,  and 
 The output and error(s) of a command can be
  appended to another file using the  symbol
 The grep filter searches the standard input or a file
  for a particular pattern of characters, and displays all
  lines that contain that pattern
 The wc filter counts the number of lines, words, and
  characters in a disk file or in the standard input


©NIIT                                  Linux/Lesson 2/Slide 18 of 20
Managing Documents
Summary (contd.)
 The cut filter is used when specific columns from the
  output of certain commands (or files) need to be
  extracted
 The tr filter is used to translate one set of characters
  to another
 A pipe is a feature through which the standard output
  of a command or user program can be sent as the
  standard input to another command or user program
 The tee command takes standard input and writes to
  standard output and to file(s)




©NIIT                                 Linux/Lesson 2/Slide 19 of 20
Managing Documents
Summary (contd.)
 The find command is used to search for a file
 The FAPs can be changed using the chmod command




©NIIT                           Linux/Lesson 2/Slide 20 of 20

More Related Content

Similar to 03 t1 s2_linux_lesson3

Linux Operating System. Unix_Lec-6.pptx
Linux Operating System.  Unix_Lec-6.pptxLinux Operating System.  Unix_Lec-6.pptx
Linux Operating System. Unix_Lec-6.pptxHITENKHEMANI
 
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.pptxSavitha74
 
Linux practicals T.Y.B.ScIT
Linux practicals T.Y.B.ScITLinux practicals T.Y.B.ScIT
Linux practicals T.Y.B.ScITvignesh0009
 
Linux file commands and shell scripts
Linux file commands and shell scriptsLinux file commands and shell scripts
Linux file commands and shell scriptsPrashantTechment
 
Introduction to Unix
Introduction to UnixIntroduction to Unix
Introduction to UnixSudharsan S
 
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 filtersAcácio Oliveira
 

Similar to 03 t1 s2_linux_lesson3 (20)

Linux Operating System. Unix_Lec-6.pptx
Linux Operating System.  Unix_Lec-6.pptxLinux Operating System.  Unix_Lec-6.pptx
Linux Operating System. Unix_Lec-6.pptx
 
Unix_QT.ppsx
Unix_QT.ppsxUnix_QT.ppsx
Unix_QT.ppsx
 
Unix_QT.ppsx
Unix_QT.ppsxUnix_QT.ppsx
Unix_QT.ppsx
 
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
 
Babitha.linux
Babitha.linuxBabitha.linux
Babitha.linux
 
Babitha.linux
Babitha.linuxBabitha.linux
Babitha.linux
 
Babitha.linux
Babitha.linuxBabitha.linux
Babitha.linux
 
Babitha.linux
Babitha.linuxBabitha.linux
Babitha.linux
 
Babitha.linux
Babitha.linuxBabitha.linux
Babitha.linux
 
Babitha.linux
Babitha.linuxBabitha.linux
Babitha.linux
 
Babitha.linux
Babitha.linuxBabitha.linux
Babitha.linux
 
Babitha.linux
Babitha.linuxBabitha.linux
Babitha.linux
 
Babitha.linux
Babitha.linuxBabitha.linux
Babitha.linux
 
Prabu linux
Prabu linuxPrabu linux
Prabu linux
 
Prabu linux
Prabu linuxPrabu linux
Prabu linux
 
Linux practicals T.Y.B.ScIT
Linux practicals T.Y.B.ScITLinux practicals T.Y.B.ScIT
Linux practicals T.Y.B.ScIT
 
Linux file commands and shell scripts
Linux file commands and shell scriptsLinux file commands and shell scripts
Linux file commands and shell scripts
 
Introduction to Unix
Introduction to UnixIntroduction to Unix
Introduction to Unix
 
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
 
Linuxs1
Linuxs1Linuxs1
Linuxs1
 

More from Niit Care (20)

Ajs 1 b
Ajs 1 bAjs 1 b
Ajs 1 b
 
Ajs 4 b
Ajs 4 bAjs 4 b
Ajs 4 b
 
Ajs 4 a
Ajs 4 aAjs 4 a
Ajs 4 a
 
Ajs 3 b
Ajs 3 bAjs 3 b
Ajs 3 b
 
Ajs 3 a
Ajs 3 aAjs 3 a
Ajs 3 a
 
Ajs 3 c
Ajs 3 cAjs 3 c
Ajs 3 c
 
Ajs 2 b
Ajs 2 bAjs 2 b
Ajs 2 b
 
Ajs 2 a
Ajs 2 aAjs 2 a
Ajs 2 a
 
Ajs 2 c
Ajs 2 cAjs 2 c
Ajs 2 c
 
Ajs 1 a
Ajs 1 aAjs 1 a
Ajs 1 a
 
Ajs 1 c
Ajs 1 cAjs 1 c
Ajs 1 c
 
Dacj 4 2-c
Dacj 4 2-cDacj 4 2-c
Dacj 4 2-c
 
Dacj 4 2-b
Dacj 4 2-bDacj 4 2-b
Dacj 4 2-b
 
Dacj 4 2-a
Dacj 4 2-aDacj 4 2-a
Dacj 4 2-a
 
Dacj 4 1-c
Dacj 4 1-cDacj 4 1-c
Dacj 4 1-c
 
Dacj 4 1-b
Dacj 4 1-bDacj 4 1-b
Dacj 4 1-b
 
Dacj 4 1-a
Dacj 4 1-aDacj 4 1-a
Dacj 4 1-a
 
Dacj 1-2 b
Dacj 1-2 bDacj 1-2 b
Dacj 1-2 b
 
Dacj 1-3 c
Dacj 1-3 cDacj 1-3 c
Dacj 1-3 c
 
Dacj 1-3 b
Dacj 1-3 bDacj 1-3 b
Dacj 1-3 b
 

Recently uploaded

New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 

Recently uploaded (20)

New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 

03 t1 s2_linux_lesson3

  • 1. Managing Documents Objectives In this lesson, you will learn to: Identify the standard input, output, and error files Use input, output, and error redirection Identify the features and options of the grep, wc, cut, and tr filters Combine multiple commands by using Pipes Locate a file by using the find command Assign File Access Permissions (FAPs) ©NIIT Linux/Lesson 2/Slide 1 of 20
  • 2. Managing Documents Standard Files Standard Input File The keyboard is referred to as the standard input file In Linux, all the open files, including the standard files, are assigned a number called the file descriptor. The file descriptor 0 is assigned to the standard input file Standard Output File The monitor is referred to as the standard output file The file descriptor 1 is assigned to the standard output file ©NIIT Linux/Lesson 2/Slide 2 of 20
  • 3. Managing Documents Standard Files (contd) Standard Error File The monitor is also the standard error file The file descriptor 2 is assigned to the standard error file ©NIIT Linux/Lesson 2/Slide 3 of 20
  • 4. Managing Documents Redirection Redirection changes the assignments for the standard input, output, and error Input Redirection The following example illustrates the use of input redirection: $ cat test1 Enter Output Redirection The following example illustrates the use of output redirection: $ cat test1 test2 ©NIIT Linux/Lesson 2/Slide 4 of 20
  • 5. Managing Documents Redirection (contd.) Error Redirection The following example illustrates the use of error redirection: $ cat datafile 2 error-mesg Enter ©NIIT Linux/Lesson 2/Slide 5 of 20
  • 6. Managing Documents Filters A filter is a program that takes its input from the standard input file, processes (or filters) it, and sends its output to the standard output file The grep Filter The grep filter searches a file for a particular pattern of characters and displays all the lines that contain that pattern. The pattern that is searched for is referred to as a regular expression grep regular_expression [filename] ©NIIT Linux/Lesson 2/Slide 6 of 20
  • 7. Managing Documents Filters (contd.) The grep Filter (contd.) Options of the grep Filter -n : This prints each line matching the pattern along with its line number -c : This prints only a count of the lines that match a pattern -v : This prints all the lines that do not match the pattern specified by the regular expression ©NIIT Linux/Lesson 2/Slide 7 of 20
  • 8. Managing Documents Filters (contd.) The wc Filter The wc filter is used to count the number of lines, words, and characters in a disk file or in the standard input wc [-lwc] [filename/s ] The cut Filter The cut filter is useful when specific columns from the output of certain commands (such as ls, who) need to be extracted cut [options] [filename/s] ©NIIT Linux/Lesson 2/Slide 8 of 20
  • 9. Managing Documents Filters (contd.) The tr Filter The tr filter can be used to translate one set of characters to another $ tr ':' ' ' /etc/passwd ©NIIT Linux/Lesson 2/Slide 9 of 20
  • 10. Managing Documents Just a Minute… The details of various customers who have registered with Diaz Telecommunications are stored in the Customers file. The sample data of the file is as follows: 000001,Angela,Smith,16223 Radiance Court,Kansas City,Kansas 000002,Barbara,Johnson,227 Beach Ave.,Alexandria,Virginia 000003,Betty,Williams,1 Tread Road,Dublin,Georgia ©NIIT Linux/Lesson 2/Slide 10 of 20
  • 11. Managing Documents Just a Minute…(contd.) Write a command to find the number of people staying in the state of Kansas Write a command to display the complete details along with the line number in which the details are present for the customer Linda ©NIIT Linux/Lesson 2/Slide 11 of 20
  • 12. Managing Documents Pipes The vertical bar (|) is the pipe character It indicates to the shell that the output of the command before ‘|’ is to be sent as input to the command after ‘|’ The tee Command The tee command takes standard input and writes to standard output to file(s) If the file where data is to be written does not exist, the file is created If the file already exists, its contents are overwritten cat temp | tee temp1 temp2 ©NIIT Linux/Lesson 2/Slide 12 of 20
  • 13. Managing Documents Just a Minute… The details of various customers who have registered with Diaz Telecommunications are stored in the Customers file. Sample data from the file is as follows: 000001,Angela,Smith,16223 Radiance Court,Kansas City,Kansas 000002,Barbara,Johnson,227 Beach Ave.,Alexandria,Virginia 000003,Betty,Williams,1 Tread Road,Dublin,Georgia ©NIIT Linux/Lesson 2/Slide 13 of 20
  • 14. Managing Documents Just a Minute…(contd.) In the file, the field delimiter is ','. The various fields are CustomerCode, FirstName, LastName, Address, City, and State. Write a command to display only the FirstName and the LastName of the customers living in Georgia ©NIIT Linux/Lesson 2/Slide 14 of 20
  • 15. Managing Documents Locating Files in Linux The find Command find [path] [expression]  The find command is used to locate a file in a particular directory and in all its subdirectories. It is the most commonly used command for locating files and has various options for advanced searches ©NIIT Linux/Lesson 2/Slide 15 of 20
  • 16. Managing Documents File Access Permissions (FAPs) File Access Permissions (FAPs) refer to the permissions associated with a file with respect to the following:  The file owner  The group owner  Other users ©NIIT Linux/Lesson 2/Slide 16 of 20
  • 17. Managing Documents Assigning Permissions to Files The chmod command chmod mode file/s The chmod command is used to change the permissions associated with a file or a directory. There are two modes for assigning the permissions: • Symbolic mode – the permissions and the type of users for whom the permission is to be granted are given in symbols. • Absolute mode – In this, a series of digits is used to represent the actual permissions. ©NIIT Linux/Lesson 2/Slide 17 of 20
  • 18. Managing Documents Summary In this lesson, you learned that: You can redirect input, output, and errors to a file other than the standard files by the file descriptors along with the redirection symbols, and The output and error(s) of a command can be appended to another file using the symbol The grep filter searches the standard input or a file for a particular pattern of characters, and displays all lines that contain that pattern The wc filter counts the number of lines, words, and characters in a disk file or in the standard input ©NIIT Linux/Lesson 2/Slide 18 of 20
  • 19. Managing Documents Summary (contd.) The cut filter is used when specific columns from the output of certain commands (or files) need to be extracted The tr filter is used to translate one set of characters to another A pipe is a feature through which the standard output of a command or user program can be sent as the standard input to another command or user program The tee command takes standard input and writes to standard output and to file(s) ©NIIT Linux/Lesson 2/Slide 19 of 20
  • 20. Managing Documents Summary (contd.) The find command is used to search for a file The FAPs can be changed using the chmod command ©NIIT Linux/Lesson 2/Slide 20 of 20