Im trying to create a variable file name, so I can make incremental backups of log files myvar=date -u +%T gzip /var/log/messages /root/$myvar #then cat /var/log/messages | tail -n 1 > /var/log/messages # this wipes out the file leaving only one line on the gzip line, I get an error "filename ambigously defined" can anyone shed so lite on this? How can I easily assign fairly random unique filenames? many thanks rob
Your setting of "myvar" is wrong. Change to read: myvar=`date -u +%T` That is, add the "backquote" around the date expression. This will set "myvar" the the "contents" or "evaluation" of the information between the backquotes. -=[cwa]=- On Mon, 26 Mar 2001, rob wrote: :)Im trying to create a variable file name, so I can make incremental :)backups of log files :) :)myvar=date -u +%T :) :)gzip /var/log/messages /root/$myvar :) :)#then :) :)cat /var/log/messages | tail -n 1 > /var/log/messages :) :)# this wipes out the file leaving only one line :) :) :)on the gzip line, I get an error "filename ambigously defined" :) :)can anyone shed so lite on this? How can I easily assign fairly random :)unique filenames? :) :)many thanks :)rob :) :) -- Christopher W. Aiken Scenery Hill, Pa, USA chris at cwaiken dot com www.cwaiken.com SuSE 7.1 Professional Linux
On Mon, 26 Mar 2001 09:09:26 -0500, rob said: | cat /var/log/messages | tail -n 1 > /var/log/messages Don't write directly to the system log. Use logger instead. -- ---------------------------------------------------- Koos Pol T: +31 20 3116122 Systems Administrator F: +31 20 3116200 Compuware Europe B.V. E: koos_pol@nl.compuware.com Amsterdam PGP public key available
participants (3)
-
Christopher W. Aiken
-
Koos Pol
-
rob