Skip to content

Instantly share code, notes, and snippets.

@atdt
Created June 6, 2012 19:15
Show Gist options
  • Select an option

  • Save atdt/2884023 to your computer and use it in GitHub Desktop.

Select an option

Save atdt/2884023 to your computer and use it in GitHub Desktop.
udp2log filter
#!/usr/bin/env bash
LOGDIR="/var/log" # destination for log files
# Reads lines from standard input. For each line, write into a log file whose
# name is generate from the first field in the line and the current date.
# Fields are whitespace-delimited. For example, the line "foo bar buzz 123"
# will be recorded in the file "foo-2012-06-06.log"
while read -r line ; do
read -r head tail <<< "${line}"
echo "${line}" >> "${LOGDIR}/${head}-$(date +%F).log"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment