I'm not sure when they were, but I remember the posts about 'tai64n'.
Anyway, there may be a case that we need log files with human readable
timestamps, both as their file names and the first column of the contents.
Today, I wrote the shell/awk script that converts the qmail log files
(whose file name start with @) into:
(out_base_dir)/yyyyMM/dd/HH_mm_ss.txt
(out_base_dir)/pop3d/yyyyMM/dd/HH_mm_ss.txt
(out_base_dir)/smtpd/yyyyMM/dd/HH_mm_ss.txt
I attached it to this e-mail.
Any suggestions are welcome to me.
Jun Inamori
For fun, a while back (sometime within the last year), I wrote something
similar to convert between the two formats.
I can't remember why I created it (specifically), but the results are
attached.
Regards,
--
dave [ please don't CC me ]
Hmmm, well, there are a few things I'd change, just for robustness
purposes. For example, I'd probably quote things much more thoroughly.
In your script you have things like:
log_dir=$1
out_dir=$2
cd $log_dir
I'd probably quote them, like this:
log_dir="$1"
out_dir="$2"
cd "$log_dir"
It helps if your directory names ever have spaces in them (for
example).
Your use of "ex_code" is superfluous, you can just do this:
if ls @* >&/dev/null ; then
echo "No file starting with @"
Also, it's probably a bad idea to use ls as your file locating tool,
because it has a tendency to like formatting listings for your
terminal rather than generating output that's good for parsing. YOUR
ls may work with this script, but it's not portable to do it the way
you have.
And generating a secondary script (time_conf.sh) to run is silly, and
only makes your script harder to read. Here, try this:
#!/bin/sh
log_dir="$1"
out_dir="$2"
mkdir -p "$out_dir"
for FILENAME in "$log_dir"/@* ; do
if [ "$FILENAME" == "$log_dir/@*" ] ; then
echo "No file starting with @ in $log_dir"
exit -1;
fi
taidate=`basename $FILENAME | tai64nlocal | cut -d. -f1`
logname=$( date -d "$taidate" +%Y%m/%d/%H_%M_%S.txt )
dirname=$( date -d "$taidate" +%Y%m/%d )
mkdir -p "$out_dir/$dirname"
tai64nlocal < "$FILENAME" > "$logname"
done
~Kyle
--
The greatest dangers to liberty lurk in insidious encroachment by men
of zeal, well-meaning but without understanding.
-- Brandeis
Thank you for your reply.
> For fun, a while back (sometime within the last year), I wrote something
> similar to convert between the two formats.
>
> I can't remember why I created it (specifically), but the results are
> attached.
I'll look into your attachment.
Have a nice weekend.
Jun Inamori
--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-...@muc.de