User Tools

Site Tools


sed

sed

sed can be used to substitute
eg. substitute : with nothing, and do for every occurrence (represented by g)

sed 's/://g'

s/X/Y/
replaces X with Y
/ represents nothing
g represents every occurance


remove multiple characters from line

Below removed [ and ]

sed 's/[][]//g'
below removes , 7 and l
sed 's/[,7l]//g'


remove anything before a character

sed 's/.*[/]//'
For example, if you are trying to get the log format for apache (centos):
grep ^ErrorLog /etc/httpd/conf/httpd.conf | awk '{print $2}' | sed 's/.*[/]//'
Returns
error_log
Sometimes format is error.log

sed.txt · Last modified: 2024/05/23 07:26 by 127.0.0.1

Except where otherwise noted, content on this wiki is licensed under the following license: Public Domain
Public Domain Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki