Wednesday, June 30, 2021

modify files using sed in linux

 sed is a powerfull tool and you can find all details from here

delete a line containing a substring ("pattern")

sed -i '/pattern/d' file
replace a string
sed -e s/pattern//g -i file
using i.backup will keep a backup file of original and it is safer.  

sed -e "s/pattern//g" -i.backup file




No comments:

Post a Comment

Optimize you working enviorenment : Single command to create & move to a directory in linux (C Shell, Bash)

Usually move to a directory just after creating is bit of a anxious task specially if the directory name is too long. mkdir long-name-of...