Re: searching for lines > 45 days
On Jan 8, 7:32 am, Peter <petercri...@yahoo.com> wrote:
> I have a field in a text file 11:39:16 2007-10-07. Is there anyway to
> use grep or a similiar tool to extract all lines over 45 days to
> another file and remove them from the original file ?
>
> Thanks,
> Pete
#!/bin/sh
t=`echo "11:39:16 2007-10-07" | sed 's/[:-]/ /g'`
set -- $t
string="$4$5$6$1$2"
touch tempfile
touch -t $string tempfile
result=`find . -mtime +45 -ls |grep tempfile > /dev/null`
if [ "$result" -eq 0 ];then
echo "Found line"
rm tempfile
fi
|