sed: Insert character in the beginning or end of line with matched 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. Before starting with some command examples let us take a file sample output where we want to perform our sed operation. Sample File “/tmp/file” with … Read more

sed: insert word or text after match in middle of the line (search and append a string before or after match)

How to append a string after a match? For eg I have a text line “This is not test” where I would like to insert “really” after matching “is“ Command: echo “This is not test” |sed ‘s/<is>/& really/’ This is really not test NOTE: Here since in the same line I had “is” twice i.e. … Read more

Script to take backup of any critical directory in Unix/Linux

This is a script which can be used to backup of  your home directory on a day basis where a compressed backup of your home directory /home will be saved inside /backup directory. You can put this script in the cron file to take backup regularly as per your requirements.(Replace the parameters in blue as per your requirement) #!/bin/bash … Read more