From owner-freebsd-stable@FreeBSD.ORG Thu Oct 16 14:42:18 2008 Return-Path: Delivered-To: freebsd-stable@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 21D7010656C3 for ; Thu, 16 Oct 2008 14:42:18 +0000 (UTC) (envelope-from olli@lurza.secnetix.de) Received: from lurza.secnetix.de (unknown [IPv6:2a01:170:102f::2]) by mx1.freebsd.org (Postfix) with ESMTP id 80F628FC19 for ; Thu, 16 Oct 2008 14:42:17 +0000 (UTC) (envelope-from olli@lurza.secnetix.de) Received: from lurza.secnetix.de (localhost [127.0.0.1]) by lurza.secnetix.de (8.14.3/8.14.3) with ESMTP id m9GEgEvj093139; Thu, 16 Oct 2008 16:42:15 +0200 (CEST) (envelope-from oliver.fromme@secnetix.de) Received: (from olli@localhost) by lurza.secnetix.de (8.14.3/8.14.3/Submit) id m9GEgCrb093138; Thu, 16 Oct 2008 16:42:12 +0200 (CEST) (envelope-from olli) Date: Thu, 16 Oct 2008 16:42:12 +0200 (CEST) Message-Id: <200810161442.m9GEgCrb093138@lurza.secnetix.de> From: Oliver Fromme To: freebsd-stable@FreeBSD.ORG, andrewd@webzone.net.au, Gary Kline In-Reply-To: <48F173A8.7000506@webzone.net.au> X-Newsgroups: list.freebsd-stable User-Agent: tin/1.8.3-20070201 ("Scotasay") (UNIX) (FreeBSD/6.4-PRERELEASE-20080904 (i386)) MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.1.2 (lurza.secnetix.de [127.0.0.1]); Thu, 16 Oct 2008 16:42:16 +0200 (CEST) Cc: Subject: Re: rsync or even scp questions.... X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: freebsd-stable@FreeBSD.ORG, andrewd@webzone.net.au, Gary Kline List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Oct 2008 14:42:18 -0000 Why was this posted to -stable? Anyway ... Andrew D wrote: > 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: I always create symlinks from /home to /usr/home or vice versa, so both of them always work. > ~kline is an alias for the home directory for the user kline. You can > use that in your scripts rather than the full path :) > As far as I know it works in all *nix variants. It's not a matter of the UNIX variant, it's a matter of the shell. Most shells support the "~" tilde expansion (FreeBSD's sh, csh, and shells from ports such as bash, ksh and zsh). However, I still recommend to use $HOME instead inside scripts for portability reasons. For example, Solaris' /bin/sh does _not_ support "~". $HOME always works. > > #!/bin/sh > > > > PWD=`pwd`; > > echo "This directory is [${PWD}]"; > > > > scp -qrp ${PWD}/* ethos:/${PWD} Many superfluous characters. You can make it shorter: 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.) The easiest way is to make a symlink from /usr/home to /home, as explained above. To answer your actual question: You can use "#" to remove a prefix in /bin/sh scripts: $ foo=/usr/home/whatever $ echo ${foo#/usr} /home/whatever If the variable doesn't have a matching prefix, the result remains unchanged. Best regards Oliver -- Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing b. M. Handelsregister: Registergericht Muenchen, HRA 74606, Geschäftsfuehrung: secnetix Verwaltungsgesellsch. mbH, Handelsregister: Registergericht Mün- chen, HRB 125758, Geschäftsführer: Maik Bachmann, Olaf Erb, Ralf Gebhart FreeBSD-Dienstleistungen, -Produkte und mehr: http://www.secnetix.de/bsd "Software gets slower faster than hardware gets faster." -- Niklaus Wirth