Sed: replace a certain pattern with an arbitrary string in between

scriptsed

I'm trying to clean up a log file for better readability – there's a load of un-necessary stuff there to my needs – i basically have to replace sshd[xxxx] where xxxx is an arbitrary number with, well, either a space or nothing. While i can replace a known string, i have no idea how to do a sed wildcard in this case- So- how do i do that?

Best Answer

its not clear whether you want the replace the "sshd" as well, so i assumed you it is.

   sed 's/sshd\[[0-9]*\]//g' file

otherwise,

   sed 's/sshd\[[0-9]*\]/sshd[]/g' file
Related Question