On 15 July 2013 09:39, Yves Crespin <[email protected]> wrote:
> Hi,
>
> I parse a files list ... and this list contains some files starting with a
> tilde.
> How can I get a tilde substitution for thoses files ?
>
> ksh -c 'typeset FILE=~/.profile; if [[ ! -f $FILE ]]; then echo not found;
> fi'
> It's OK : tilde expansion
>
> ksh -c 'typeset FILE="~/.profile"; if [[ ! -f $FILE ]]; then echo not found;
> fi'
> It's OK : no tilde expansion
>
> ksh -c 'typeset FILE="~/.profile"; typeset EXPAND=$FILE; if [[ ! -f $EXPAND
> ]]; then echo not found; fi'
>
> + FILE='~/.profile'
> + typeset FILE
> + EXPAND='~/.profile'
> + typeset EXPAND
> + [[ ! -f '~/.profile' ]]
> + echo not found
> not found
>
> Version JM 93u+ 2012-02-29

Put the tilde outside the "", e.g.
ksh -c 'x="~/.profile" ; print $x'
~/.profile
ksh -c 'x=~/".profile" ; print $x'
/home/cons/.profile

Lionel
_______________________________________________
ast-users mailing list
[email protected]
http://lists.research.att.com/mailman/listinfo/ast-users

Reply via email to