Re: rsync or even scp questions....
Why was this posted to -stable? Anyway ...
Andrew D <andrewd@webzone.net.au> wrote:[color=blue]
> Gary Kline wrote:[color=green]
> > 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:[/color][/color]
I always create symlinks from /home to /usr/home or vice
versa, so both of them always work.
[color=blue]
> ~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.[/color]
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.
[color=blue][color=green]
> > #!/bin/sh
> >
> > PWD=`pwd`;
> > echo "This directory is [${PWD}]";
> >
> > scp -qrp ${PWD}/* ethos:/${PWD}[/color][/color]
Many superfluous characters. You can make it shorter:
scp -qrp $PWD/* ethos:$PWD
[color=blue][color=green]
> > ###/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.)[/color][/color]
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: [url]http://www.secnetix.de/bsd[/url]
"Software gets slower faster than hardware gets faster."
-- Niklaus Wirth
_______________________________________________
[email]freebsd-stable@freebsd.org[/email] mailing list
[url]http://lists.freebsd.org/mailman/listinfo/freebsd-stable[/url]
To unsubscribe, send any mail to "freebsd-stable-unsubscribe@freebsd.org"