Skip to Content
Learning Linux Shell Scripting - Second Edition
book

Learning Linux Shell Scripting - Second Edition

by Ganesh Sanjiv Naik
May 2018
Beginner
332 pages
7h 28m
English
Packt Publishing
Content preview from Learning Linux Shell Scripting - Second Edition

Printing – the p command

By default, the action of the sed command is to print the pattern space, such as every line that is copied into the buffer, and then print the result of processing it. Therefore, the sed output will consist of all lines along with the processed line by sed. If we do not want the default pattern space line to be printed, then we need to give the -n option. Therefore, we should use the -n option and the p command together to see the result of the sed processed output.

Here is an example:

    $ cat country.txt
  

The output is as follows:

    Country     Capital     ISD Code
    USA         Washington  1
    China       Beijing     86
    Japan       Tokyo       81
    India       Delhi       91
    
    $ sed '/USA/p' country.txt
  

The output is as follows:

    Country     Capital     ISD Code
    USA Washington 1 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning Linux Shell Scripting

Learning Linux Shell Scripting

Ganesh Sanjiv Naik
Linux Shell Scripting Cookbook - Third Edition

Linux Shell Scripting Cookbook - Third Edition

Clif Flynt, Sarath Lakshman, Shantanu Tushar

Publisher Resources

ISBN: 9781788993197Supplemental Content