Date: Thu, 16 Oct 2008 16:42:12 +0200 (CEST) From: Oliver Fromme <olli@lurza.secnetix.de> To: freebsd-stable@FreeBSD.ORG, andrewd@webzone.net.au, Gary Kline <kline@thought.org> Subject: Re: rsync or even scp questions.... Message-ID: <200810161442.m9GEgCrb093138@lurza.secnetix.de> In-Reply-To: <48F173A8.7000506@webzone.net.au>
next in thread | previous in thread | raw e-mail | index | archive | help
Why was this posted to -stable? Anyway ... Andrew D <andrewd@webzone.net.au> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200810161442.m9GEgCrb093138>