Given this little script called homedir
#!/bin/sh
echo ~$1
I expected homedir niall (or whatever) to return /home/niall (or whatever).
However, t'ain't so. A little R'ing of the FM revealed the reason to be that
tilde expansion is performed BEFORE variable expansion, and this is
apparently not negotiable. Any bash geniuses out there able to figure out a
neat way around this ? Bear in mind that what I need to do is find a user's
home directory in a script, and a little bit of awk will do it for me, so
exceedingly complex solutions don't get any cigar.
Regards,
Niall
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!