Making a replace.sed file for replacing all occuring A with B in a file:
bash$ echo "1,"\$s":VALUE_A:_VALUE_B:g" >> replace.sed
bash$ sed -f replace.sed < currentfile > newfile
Getting Nth line in a text file:
bash$ sed -n '1~4p' somefile
This command will get every 4th line starting from line 1
Adding anything in from of the line:
bash$ sed 's/^/<ANYTHING>/'
Replacing the word enchantment with entrapment from line 1 to 10 in the myfile.txt:
bash$ sed -e '1,10s/enchantment/entrapment/g' myfile.txt
Search and replace within VI:
First occurrence on current line:
:s/OLD/NEW
Globally (all) on current line:
:s/OLD/NEW/g
Between two lines #,#:
:#,#s/OLD/NEW/g
Every occurrence in file:
:%s/OLD/NEW/g