|
From: | kai |
Subject: | Re: [Help-bash] handling variables with tilde character |
Date: | Wed, 04 Jul 2012 00:28:07 +0400 |
User-agent: | Roundcube Webmail/0.5.2 |
Hello Chet,
Tilde expansion of variables doesn't work. The characters between thetilde and the slash or end of the string are treated as a username.
that's exactly what i'm trying to do - use variables with tilde as an username. but bash seems to just ignore them. here is an example with touch:
00:21:18||/root# touch ~kai/123 00:21:27||/root# ls -la ~kai/123 -rw-r--r-- 1 root root 0 Jul 4 00:21 /home/kai/123 00:21:32||/root# rm ~kai/123 00:21:36||/root# ls -la ~kai/123 ls: cannot access /home/kai/123: No such file or directory 00:21:38||/root# user="kai"; touch ~$user/123 00:21:48||/root# ls -la ~kai/123 ls: cannot access /home/kai/123: No such file or directory previous email shows that mkdir doesn't work either. testing with echo: 00:25:42||/root# user="kai"; echo test > ~$user/123 bash: ~kai/123: No such file or directory 00:26:43||/root# echo test > ~kai/123 00:26:47||/root# cat ~kai/123 testvariable still doesn't work. how shoild i use "~$username" pattern with commands?
Cheers, Kai
[Prev in Thread] | Current Thread | [Next in Thread] |