# The [ needs to be escaped to prevent grep from treating # it as a glob rule expansion #grep ' sshd\[' messages.1 # This will grep for any sshd command that has a # 4 digit PID following the name of the command. grep ' sshd\[[0-9][0-9][0-9][0-9]\]' messages.1