parsed.org

Tips by tag: chop

Log Chopping by xinu on Jan 12, 2005 11:01 AM

Given a log file with a date in the first column, chop up the file into separate file:

$ awk '/^[0-9]/ {print $0 > $1".log"}' logfile.txt

If you have a string that has characters that the shell won't like, you can do a substitution on them:

$ awk '{gsub("/","_",$1); print $1 > $1".log"}' logfile.txt
awkchoplogshellsplit
RSS