Cut Huge
Log Files in Half
Ever get those huge log files that you just can not bring into a vi editor, because of buffer overruns of the lack of disk space in /tmp. Cut the file in half. 1) Find the number of lines in the log file: % wc -l SYSLOG
2) Divide this number in half % echo "1234567 / 2" | bc
3) For the first half of the file: % tail +617283 SYSLOG > SYSLOG.half For the bottom half of the file: % tail -617283 SYSLOG > SYSLOG.half The script may look like this: #! /bin/sh
FILE=$1 if [ -z "$FILE" ]; then
SIZE=`cat $FILE | wc -l`
echo "Total size = $SIZE Half = $HALF"
Have a Unix Problem
Unix Books :-
Return to : - Unix System Administration Hints and Tips (c) www.gotothings.com All material on this site is Copyright.
|