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_logSometimes format is error.log
sed.txt · Last modified: 2024/05/23 07:26 by 127.0.0.1