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 Add Hyperlink to Another Sheet in Excel?
  • How to Add and Remove Watermark in Excel
  • How to use Relative and Absolute Cell Reference in Excel?
  • How to Enable and Disable Scroll Lock in Excel?
  • How to Use INDEX and MATCH Functions in Excel?
  • How to Make Bar Graph in Excel?
  • How to Count Duplicate Values in Excel?
  • How to Wrap Text in Excel?
  • How to Round off Numbers in Excel?
  • How to Create a Bell Curve in Excel?

Related Searches

  • How to Schedule Restart for Updates in Windows 10
  • How to enable right side chat in gmail
  • How to Rotate Screen in Windows 7?
  • How to Install Classic Gnome menu in Ubuntu 14.04
  • How to install lamp (Linux, Apache, MySQL and Php) in Ubuntu 14.04

Copyright © 2023 · QueHow · Contact Us