Linux Reference6.1.3 inline rotate (keep <n> lines) |
20.02.2008 |
| ← 6.1.2 Character conversions | [ up ] - [ top ] - [ linux a-z ] | 6.1.4 wget → |
# cat /usr/local/bin/inlinerotate.sh #!/bin/bash # Usage: inlinerotate.sh <file> <num_lines> <owner> <group> # e.g. inlinerotate.sh /tmp/foo.log 999 nobody nobody echo $1 - keep $2 lines tail -$2 "$1" > /tmp/__tmp_$$ mv -f /tmp/__tmp_$$ "$1" chown $3:$4 "$1"
copyright by retoh - created with mytexi