QueHow

A How-To and wiki Blog

  • Operating System
    • Windows
      • Windows 10
      • Windows 7
    • Linux
  • Software
    • Application Software
    • Microsoft Office
      • Outlook
      • Word
      • PowerPoint
  • Internet
    • Browsers
      • Mozilla Firefox
      • Google Chrome
    • CMS
    • Tips & Tricks
  • Website
    • ecommerce
    • Google
    • Social Networking
    • General Websites
  • Mobile
  • Email
    • Gmail
  • Wiki

How to Use SED Command in Ubuntu

By Neha T Leave a Comment

Do you want to use SED commands in Ubuntu?. Great, but first you must understand the concept of SED. Basically SED is a stream editor, where stream refers to a file. It performs editing operation of a text on a file. It is a very powerful tool which is used to transform text.

SED goes through the input stream line by line, places it in stack pattern and then executes the command one by one. Just have a glance at this article to know how to use SED command in Ubuntu.

Steps to Use SED Command in Ubuntu

Step 1: Let’s see the version of “sed” available on your system, type “sudo sed – -version” and press enter.

how-to-use-sed-command-in-ubuntu-step1

Step 2: The output of the above command will be visible to you.

how-to-use-sed-command-in-ubuntu-step2

Step 3: Now suppose, if you want to create a project report named as “project.txt” and insert the names of your team member, and at the same time, you are required to change one of the member name like Ishita to Namita and then want to save it to a file “project2.txt”.

So write: “sudo sed s/Ishita/Namita/ project.txt >project2.txt” where “s” is known for the substitute, it can be used with various options.

how-to-use-sed-command-in-ubuntu-step3

Step 4: To test whether it is done or not, use the command “echo Ishita | sed s/Ishita/Namita/”, and press enter.

how-to-use-sed-command-in-ubuntu-step4

Step 5: Output of the above command is shown below and hence it can be seen, that the name is changed to Namita.

how-to-use-sed-command-in-ubuntu-step5

Step 6: Now to have a clear vision, you can use “cat” command to get the full content of a file.

Type “cat filename”, in my case, I have written “cat project2.txt”.

Press Enter.

how-to-use-sed-command-in-ubuntu-step6

Step 7: For an instance, if you type a message using the “echo” command and then without deleting it, you wish to print only the specific part of that message. So type: echo “hello guys, This is just an example.” | sed ‘s/^.*\(, This is.*\)/\1/g’, I have taken this example to explain you the effect of “sed” with ^. *”.

The expression “^.*” will match the character of the string until the last word.

how-to-use-sed-command-in-ubuntu-step7

You Might Also Like:

How to Create a Text File using Command Line in Ubuntu 14.04 ( 2 Methods) how-to-copy-and-move-files-and-directories-in-ubuntuHow to Copy and Move Files & Directories in Ubuntu How to use ‘tar’ command to create archives in Ubuntu 14.04 How to Configure Sudo wait time in Ubuntu 14.04 How to Display your Password while using Terminal in Ubuntu 14.04 How to Install VIM editor in Ubuntu ? How to convert pdf file to text file in Ubuntu 14.04 How to use VIM Editor in Ubuntu?

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Most Viewed

  • How to Install and Use TELNET in Ubuntu
  • How to install Hindi fonts in MS Word
  • How to Change a File Extension in Windows 10?
  • How to create a flipkart account in 3 simple steps
  • How to Change Monitor Refresh Rate in Windows 10?
  • How to install IIS on Windows 10
  • How to Insert Clickable Checkbox in MS Word 2016?
  • How to Set Auto Reply in Outlook 2016?
  • How to Login as Administrator in Windows 10?
  • How to Check RAM Size and System Type in Windows 10?

Recent Additions

  • How to Deactivate Account in Instagram?
  • How to Download Private Instagram Stories?
  • How to Slow Motion a Video in PowerDirector?
  • How to Check Who Unfollow You On Instagram?
  • How to Use Boomerang on Instagram?
  • How to Edit Video in PowerDirector?
  • How to Mute Someone’s Stories or Posts on Instagram?
  • How to Hide and Unhide Posts on Instagram?
  • How to Change Video Background in PowerDirector?
  • How to Make a Video Call on Instagram?

Related Searches

  • How to add notes in gmail
  • How to print a Booklet using Adobe Reader
  • How to Check RAM Type, Size on Windows 7
  • How to Change Default Browser in Windows 10?
  • How to use Mail Merge in MS Word 2016?

Copyright © 2021 · QueHow · Contact Us