Created
June 6, 2012 19:15
-
-
Save atdt/2884023 to your computer and use it in GitHub Desktop.
udp2log filter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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