sed: add or append character at beginning or end of line (row) of a file

You may have some requirement wherein you have to cut a row or get some output from a file and append it to another file as a prefix or suffix. or you know that you have to add some content as a prefix or suffix in front of every line of a file ot may ... Read more sed: add or append character at beginning or end of line (row) of a file

sed: Ignore whitespace while matching a pattern

In my last articles I had shared the arguments with sed which can be used to perform case insensitive actions (search, replace..) in a file and to delete all blank lines from the file. Now suppose you have a set of words or line which want to match and perform some activity but you do ... Read more sed: Ignore whitespace while matching a pattern

sed: perform search and replace only on specific lines (not globally)

By default when we perform search and replace action using sed, that is done globally within a file. Although if you have a line number you can perform the replace based on the line number but what if you have a file where you don't know the line number?Let us got through different examples where ... Read more sed: perform search and replace only on specific lines (not globally)

sed: delete all blank lines from a text file

Here our requirement is to remove all the blank lines from a file. Our sample file [root@golinuxhub ~]# cat /tmp/file This is line one This is line two This is line three This is line four [root@golinuxhub ~]# Use the below command to remove all the blank lines from a text file [root@golinuxhub ~]# sed ... Read more sed: delete all blank lines from a text file

sed: case insensitive actions (search replace delete..)

In this article I will show you different ways to perform an action (as per your requirement) ignoring the case of the letters to be searched in a file Below is our sample file # cat /tmp/file one Two three Three two One   Perform a case insensitive search and replace By default if I ... Read more sed: case insensitive actions (search replace delete..)

10 Basic examples of SED to perform per line action (print/delete)

In this article I will show you various sed expressions which can be used and combined to print or delete specific line from a file IMPORTANT NOTE: My examples provided are only to print the action performed, to use the same for delete action remove '-n' and replace 'p' with 'd' on individual command To ... Read more 10 Basic examples of SED to perform per line action (print/delete)