From owner-freebsd-questions@FreeBSD.ORG Mon Oct 13 05:44:23 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 431A2106569B for ; Mon, 13 Oct 2008 05:44:23 +0000 (UTC) (envelope-from kline@thought.org) Received: from aristotle.thought.org (aristotle.thought.org [209.180.213.210]) by mx1.freebsd.org (Postfix) with ESMTP id D37548FC1B for ; Mon, 13 Oct 2008 05:44:22 +0000 (UTC) (envelope-from kline@thought.org) Received: from thought.org (tao.thought.org [10.47.0.250]) (authenticated bits=0) by aristotle.thought.org (8.14.2/8.14.2) with ESMTP id m9D5iX44028513; Sun, 12 Oct 2008 22:44:34 -0700 (PDT) (envelope-from kline@thought.org) Received: by thought.org (nbSMTP-1.00) for uid 1002 kline@thought.org; Sun, 12 Oct 2008 22:44:16 -0700 (PDT) Date: Sun, 12 Oct 2008 22:44:15 -0700 From: Gary Kline To: Matthew Seaman Message-ID: <20081013054415.GB6708@thought.org> References: <7708.70177.qm@web56801.mail.re3.yahoo.com> <48F1B87E.6010803@infracaninophile.co.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <48F1B87E.6010803@infracaninophile.co.uk> User-Agent: Mutt/1.4.2.3i X-Organization: Thought Unlimited. Public service Unix since 1986. X-Of_Interest: With 22 years of service to the Unix community. X-Spam-Status: No, score=-4.4 required=3.6 tests=ALL_TRUSTED,AWL,BAYES_00, DNS_FROM_SECURITYSAGE autolearn=no version=3.2.3 X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on aristotle.thought.org Cc: mdh_lists@yahoo.com, FreeBSD Mailing List Subject: Re: rsync or even scp questions.... X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Oct 2008 05:44:23 -0000 On Sun, Oct 12, 2008 at 09:42:38AM +0100, Matthew Seaman wrote: > mdh wrote: > >--- On Sat, 10/11/08, Gary Kline wrote: > >> On the Ubuntu computer I am /home/kline; on my main > >>computer, > >> my home is /usr/home/kline. The following sh script > >>worked > >> perfected when my home on "tao" [FBSD] was > >>/home/kline: > >> > >>P > >>#!/bin/sh > >> > >>PWD=`pwd`; > >>echo "This directory is [${PWD}]"; > >> > >>scp -qrp ${PWD}/* ethos:/${PWD} > >>###/usr/bin/scp -rqp -i /home/kline/.ssh/zeropasswd-id > >>${PWD}/* \ klin > >>e@ethos:/${PWD} > >> > >> Question #1: is there any /bin/sh method of getting rid of > >>the > >> "/usr"? I switch off between my two computers > >>especially when > >> get mucked up, as with my upgrade to kde4. (Otherwise, I > >>do > >> backups of ~kline as well as other critical directories.) > >> > >> Is there a way of automatically using rsync rather that my > >> kwik-and-dirty /bin/shell script? > >> > >> thanks, people, > >> > >> gary > > > >If what you wish to do is simply get rid of /usr in a string, you can use > >sed like so: > >varWithoutUsr=`echo ${varWithUsr} |sed -e 's/\/usr//'` > >After running this, where $varWithUsr is the variable containing a string > >like "/usr/home/blah", the variable $varWithoutUsr will be equal to > >"/home/blah". I create simple scripts like this all the time to rename > >batches of files, for example. > >The easier way is probably just to not specify a dir to scp's remote path > >though, since it defaults to the user's home directory. > > Or, in anything resembling Bourne shell: > > varWithoutUsr=${varWithUsr#/usr} I'll be damrned! It works--I've used the zsh for almost 20 years; it's a ksh clone++. How, may I ask, does this work? (I've seen ksh chopping from the RHS; I wrote a short C util to axe any part of a string, but have never seen *this* voodoo. LOL++) In any event, merci infiniement! gary PS: this will save my rsync scripts too. > > Cheers, > > Matthew > > -- > Dr Matthew J Seaman MA, D.Phil. 7 Priory Courtyard > Flat 3 > PGP: http://www.infracaninophile.co.uk/pgpkey Ramsgate > Kent, CT11 9PW > -- Gary Kline kline@thought.org http://www.thought.org Public Service Unix http://jottings.thought.org http://transfinite.thought.org