sed: match string and append new line (before or after)

Before is the requirement for this example. I have a sample file with below content at /tmp/file This is line one This is line two This is line three This is line four Here in we have to put our content "your text" at one line before the string is matched  one line after the ... Read more sed: match string and append new line (before or after)

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 character in the beginning or end of line with matched pattern

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 sed: insert word or text after match in middle of the line (search and append a string before or after match)

How to run any script or cron job in Linux for every second

There was this one time when I ran into the situation when my /tmp partition was getting full at 100% and I got an threshold alert but again when I checked the same it was never utilizing  more than 20%. So I planned to monitor the changes inside my /tmp directory in seconds so that ... Read more How to run any script or cron job in Linux for every second

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 Script to take backup of any critical directory in Unix/Linux