Or you could write a more concise variant by avoiding the
cat, which is not necessary:
Code:
grep Accepted /var/log/secure
Another option, if there are a lot of other non-SSH related log entries would be to use AWK to guarantee that "Accepted" lines are only shown for SSH:
Code:
awk '$5~/sshd/ && $6="Accepted"' /var/log/secure
The $5 and $6 refer to the fifth and sixth fields respectively. The ~// binds the pattern search to the preceding field, which in that case is the fifth.