From LedHed's Wiki
(Created page with '== Inline Find and Replace == To do an inline find and replace using sed use the following syntax sed -i s/<FIND_TEXT>/<REPLACE_TEXT>/g -i = Inline<br> s/ = Search<br> /g = G...') |
|||
(One intermediate revision by the same user not shown) | |||
Line 3: | Line 3: | ||
To do an inline find and replace using sed use the following syntax | To do an inline find and replace using sed use the following syntax | ||
− | sed -i s/<FIND_TEXT>/<REPLACE_TEXT>/g | + | sed -i 's/<FIND_TEXT>/<REPLACE_TEXT>/g' /path/to/file.txt |
-i = Inline<br> | -i = Inline<br> | ||
s/ = Search<br> | s/ = Search<br> | ||
/g = Global<br> | /g = Global<br> | ||
+ | |||
+ | |||
+ | == Reference == | ||
+ | http://www.brunolinux.com/02-The_Terminal/Find_and%20Replace_with_Sed.html | ||
+ | |||
+ | |||
[[Category:Linux]] | [[Category:Linux]] | ||
[[Category:FreeBSD]] | [[Category:FreeBSD]] |
Latest revision as of 16:31, 8 July 2010
Inline Find and Replace
To do an inline find and replace using sed use the following syntax
sed -i 's/<FIND_TEXT>/<REPLACE_TEXT>/g' /path/to/file.txt
-i = Inline
s/ = Search
/g = Global
Reference
http://www.brunolinux.com/02-The_Terminal/Find_and%20Replace_with_Sed.html