Practising Shell Scripting
sed with -i : edit the file
sed without -i : will print the change on output
-e is for multiple coniditons in sed commands
1. Search and replace / Substitute
sed -i -e 's/root/ROOT/g' 's/admin/ADMIN/g' sample.txt
sed -i -e 'id' -e '/root/ d' sample.txt
sed -i -e '/root/ i Hello World' sample.txt
To search and replace root with ROOT
sed -i -e 's/root/ROOT/g' /tmp/passed
To delete the second line
sed -i -e '2d' /tmp/passed
To delete the line containing world ROOT
sed -i -e '/ROOT/d' /tmp/passed
To insert a new line at first place
sed -i -e '1 i Hello World' /tmp/passed
To append a new line after first line
sed -i -e '1 a New World' /tmp/passed
To replace the line with Hello Universe where the word World present
sed -i -e '/World/ c Hello Universe' /tmp/passed
To Interrupt on Shell prompt - CTL + C
To comment the selected text - CTL + /
To come out from Mongo Shell - CTL + D
To clear screen on Shell Prompt - CTL + L