Skip to main content
2 of 4
added 6 characters in body
Marcus Müller
  • 51.6k
  • 4
  • 79
  • 121

Print fields from logs with time/date and value

Using only grep and awk is it possible to print MMM DD HH:MM:SS plus another field (e.g. SRC) from a log file? This should list Source addresses from my log file but I do not know how to add the date at the beginning?

grep PROTO=TCP logfile | awk -F, '{for(i=1;i<=NF;i++){if($i=="SRC"){print $i}}}'