SED is a very powerful utility which allows find and replace/insert text functionality. It should be used with Caution and is recommended to use dry-run before committing the changes. Below are the various commands for text manipulation.

Note: \n = for newline and \t = for TAB space and For dry run just remove "-i" from the command

 Find the pattern and Insert text AFTER

# sed -i 's/.*search 1st Line.*/&\nInsert 2nd line/' file1

Add a comment

Its possible to run a script via Alias command. All you need is to modify the .bashrc and then source the script in the required user profile. Alias commands are very useful when it comes to running shortened versions of commands or a complex script to be run using just a single line of command. Currently I use this to run 2 of my custom scripts for waking up a ESXi server via WOL (Wake-ON-LAN).

Add a comment

Page 1 of 4

Most Read Articles

Add/Detect a new disk in ...

Written By Farooq Mohammed Ahmed on Sunday, 11 January 2015 19:22
Add/Detect a new disk in ...

Replace SSL Certificates ...

Written By Farooq Mohammed Ahmed on Friday, 16 December 2016 08:05
Replace SSL Certificates ...

Using awk in Alias Comman...

Written By Farooq Mohammed Ahmed on Friday, 19 February 2016 14:22
Using awk in Alias Comman...

Sed - Insert Text before ...

Written By Farooq Mohammed Ahmed on Monday, 20 November 2017 00:58
Sed - Insert Text before ...

Script to Monitor Nagios ...

Written By Farooq Mohammed Ahmed on Monday, 18 July 2016 22:48
Script to Monitor Nagios ...