Re: Shell Script help for backup
От | strange@nsk.yi.org |
---|---|
Тема | Re: Shell Script help for backup |
Дата | |
Msg-id | 20020729094445.B1866@nsk.yi.org обсуждение исходный текст |
Ответ на | Re: Shell Script help for backup (Bruce Momjian <pgman@candle.pha.pa.us>) |
Список | pgsql-general |
On Sun, Jul 28, 2002 at 11:22:22PM -0400, Bruce Momjian wrote: > > You can do 'zcat < file' to prevent the *.Z requirement. Yes, head -n > should work fine. Hm... I missed the other email, so I'm replying to this: The "$( zcat /folder/pg_backup.$DATE.gzip | head -c1 | wc -c )" is to check if there are any bytes stored in the gzip file. If the zcat expects an .Z file, try with gzcat file, gzcat < file, or gzip -d < file. head -c1 is meant to stop the decompression at the first byte, I didn't want it to wait until full decompression of the gzipped file, and I didn't use -n because then it would depend on the internal format of the decompressed file (if it was a binary file, a newline could appear only after quite some time). If you're going to use head -n1, then change the test to: [ "$( gzip -d < /folder/pg_backup.$DATE.gzip | head -n1 | wc -c )" -ge 1 ] (ie, instead of checking if bytes == 1, check if bytes >= 1). Regards, Luciano Rocha -- Consciousness: that annoying time between naps.
В списке pgsql-general по дате отправления: