[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: log-file output in separate files



On February 25, 2004 03:28 am, Paal Marker wrote:
> I need to store excerpts of logfiles in separate files from remote server.
>
> Usually I use the commands:
> grep -n "expression" /var/log/logfile
> and
> tail --lines=x /var/log/logfile
>
> ...for getting output
>
> Is there a way to give these commands and then the output is
> automatically stored in a new file?


Paal,
if use something like the expressions in the previous posts by Reuben and 
James, the date  command can be used to create unique filenames each time the 
script is run.

example:
DATE=`date +%s`  (would give you epoch, which may not add much meaning)
or maybe
DATE=`date +%y-%j-%H%M%S` (have a look at 'man date', it does lots)

 grep -n "expression" /var/log/logfile > newfile.$DATE

-- 
Pete Nesbitt, rhce




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]