From owner-freebsd-questions Mon Mar 17 12:11:27 2003 Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C0C5537B401 for ; Mon, 17 Mar 2003 12:11:24 -0800 (PST) Received: from gatekeeper.microcell.ca (gatekeeper.microcell.ca [205.151.8.2]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6D34243F85 for ; Mon, 17 Mar 2003 12:11:23 -0800 (PST) (envelope-from SoHo@admin.fido.ca) Received: from mailserv.microcell.ca (mailserv.microcell.ca [10.2.0.87]) by gatekeeper.microcell.ca (Postfix) with ESMTP id 1E5BF16CC8; Mon, 17 Mar 2003 15:11:16 -0500 (EST) Received: from 127.0.0.1 (localhost [127.0.0.1]) by mailserv.microcell.ca (Postfix) with SMTP id D934316BC9; Mon, 17 Mar 2003 15:11:15 -0500 (EST) Received: from lenard.admin.fido.ca (lamus.fido.ca [10.0.1.45]) by mailserv.microcell.ca (Postfix) with ESMTP id 1EFA316BC9; Mon, 17 Mar 2003 15:11:15 -0500 (EST) Received: from magni.microcell.ca (magni.microcell.ca [10.6.22.102]) by lenard.admin.fido.ca (SMTP_Gateway) with ESMTP id DB80C47D3C; Mon, 17 Mar 2003 15:11:08 -0500 (EST) Received: from magni.microcell.ca (localhost [127.0.0.1]) by magni.microcell.ca (8.12.6/8.12.7) with SMTP id h2HK9lfa061412; Mon, 17 Mar 2003 15:09:47 -0500 (EST) (envelope-from SoHo@admin.fido.ca) Date: Mon, 17 Mar 2003 15:09:47 -0500 From: Edmond Baroud To: Tom Parquette Cc: freebsd-questions@FreeBSD.ORG Subject: Re: Shell scripting questions Message-Id: <20030317150947.6570b8a7.SoHo@admin.fido.ca> In-Reply-To: <3E762419.3040900@twcny.rr.com> References: <3E762419.3040900@twcny.rr.com> X-Mailer: Sylpheed version 0.8.10 (GTK+ 1.2.10; i386-portbld-freebsd4.7) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Sanitizer: This message has been sanitized! X-Sanitizer-Rev: $Id: Sanitizer.pm,v 1.64 2002/10/22 16:37:04 bre Exp $ Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Mon, 17 Mar 2003 14:38:01 -0500 Tom Parquette wrote: > I've been looking through some basic shell books, and some online > resources, that I have but I'm not finding the answer. > Or maybe I just don't recognize the answer when I see it... > > I'm building a schell script that will backup my systems to CD-ROM. Or > DVD when I can talk my wife into a burner. :-) > > I'm stuck on two items: > 1) Since my tar files CAN exceed the capacity of a CD-ROM, I want to > check in the script if I have to call split. > The closest I can come to determining the size of the output file from > tar (e.g.ad0s1a.tgz) is: file_size=`du -k /tmp/ad0s1a.tgz`. > The problem I have is, while this gives me the result in number of K > blocks, it also returns the file name and directory. I don't know how > to get JUST the number of K blocks so I can do a numeric compare against > 700m. file_size=`du -k /tmp/ad0s1a.tgz|awk '{print $1}'` num_compare=`expr 700000 - $file_size` > > 2) I have a function written that will tar/gzip the filesystem then > split it into pieces that will be turned into .iso files that will be > fed to burncd. I would like to capture the output of commands (e.g. ls > -l /tmp/ad0s1a.*) into a "table" that I can examine to determine what > was output by the split command so I know what mkisofs commands, and how > many, I have to build/execute. Example: If I end up with a > ad0s1a.tgz.aa, ab, and ac from split, I know I have to do mkisofs' for 3 > files. I don't know what your split command returns but I beleive u can put that in a loop. > > I also hope to use the same technique for determining what filesystems > I have to backup in the first place. e.g. If I do a df command I want > to pull out the filesystem name and what mountpoint it is on. The > mountpoint is important to me because I do not want to back up some > filesystems. e.g. I do not want to backup /tmp. I think that all u're missing here is the "awk" command. man awk ;) fs=`df|awk '{print $6}'|grep -vi mounted` for i in $fs do if [ $i = "/" ] then backup_script args elseif [ $i = "/etc" ] backup_script args else elseif [ $i = "/tmp" ] echo "I'm not backing up /tmp !" else do something fi done > > TIA. > Cheers... hope this helps. Ed. > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-questions" in the body of the message -- Edmond Baroud UNIX Systems Admin mailto:SoHo@admin.fido.ca Fingerprint 140F 5FD5 3FDD 45D9 226D 9602 8C3D EAFB 4E19 BEF9 "UNIX is very user friendly, it's just picky about who its friends are." To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message