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)

sed: remove all leading and ending blank whitespace from a file

Here our requirement is to remove all the whitespace from the leading and ending space per line of a file. Our sample file /tmp/file    This is line one   This is line two          This is line three         This is line four Remove all leading whitespace To ... Read more sed: remove all leading and ending blank whitespace from a file

sed: Insert multiple lines before or after pattern match

In my last articles I had shown you the arguments to be used with sed to add or append any character in the beginning or end of the line and to ignore whitespace while grepping for a pattern so that the grep does not fails if there is an extra whitespace character between two words ... Read more sed: Insert multiple lines before or after pattern match

sed: Replace string based on line number (certain line)

Here our requirement is that we have a file where we have to perform a string replacement but based on line number. Below is our sample data /tmp/file 1 This is line one 2 This is line two 3 This is line three 4 This is line four 5 This is line one 6 This ... Read more sed: Replace string based on line number (certain line)

sed :Replace whole line when match found

Here our requirement is to replace a line with our content when a match is found with in the file Our sample file /tmp/file This is line one This is line two This is line three This is line four Here we will search for line having the string "two" and replace the complete line ... Read more sed :Replace whole line when match found