Questions tagged [tilde-expansion]

Tilde expansion is a feature of the POSIX shell providing shortcut access to users' home directories.

Tilde expansion is a feature of POSIX shells providing shortcuts for the users' home directories:

~ # current user's home directory
~bob # home directory of the user named 'bob'
67 questions
5
votes
3 answers

Open an ofstream with tilde (~) in path name

I have to open some file for writing, and its name contains the tilde sign (~). The following code fails to create the desired text file. If I replace the ~ with /home/oren then everything works fine. #include #include const…
OrenIshShalom
  • 5,974
  • 9
  • 37
  • 87
5
votes
1 answer

shell tilde expansion does not work when passed as an option

I find tilde expansion does not work for the following situation: $ set -x $ ./print_arg.pl destdir=~/test + ./print_arg.pl 'destdir=/root/test' destdir=/root/test $ ./print_arg.pl dest-dir=~/test + ./print_arg.pl…
lisper
  • 75
  • 1
  • 6
4
votes
1 answer

Is there any official documentation specifying that ~ (tilde) resolves to node_modules/ in Angular scss import paths?

When using a tilde (~) in scss import paths, it expands to node_modules/ in Angular. Is there any piece of official documentation that says that this is a feature of either Angular or webpack? All I have found on the matter so far is a few bug…
Christian
  • 6,070
  • 11
  • 53
  • 103
4
votes
1 answer

No such file or directory (ls) in conjunction with tilde expansion

I am writing a simple bash script and wanted to display all the items in a a particular directory. I tried doing the following: desktop="~/Desktop/testr/" echo $desktop echo `ls $desktop` However I keep getting the output: ~/Desktop/testr/ ls:…
babaloo
  • 435
  • 5
  • 24
4
votes
1 answer

Tilde-based Paths in Objective-C

In Objective-C, how do I go about converting tilde-based pathnames to full pathnames? That is, I'd like to convert from ~/sandbox to /Users/TheBobs/sandbox.
zanussi
  • 1,286
  • 2
  • 22
  • 29
4
votes
1 answer

cygwin tilde expansion not working in interactive shell

For some reason tilde expansion in Cygwin is not working for me at the prompt: $ ls ~ ls: cannot access : No such file or directory $ ls ~/bin (lists /bin not $HOME/bin) $ echo $HOME /home/myusername $ echo ~ $ In the last case there (echo ~)…
ErikR
  • 51,541
  • 9
  • 73
  • 124
3
votes
2 answers

Expand variable before tilde

I'm sure this has been asked before but I can't find anything. We have inscrutable login names on a shared machine and want to use shell variables to substitute the hard-to-remember login names for people's real names. For example, let's say Omar's…
JohnE
  • 29,156
  • 8
  • 79
  • 109
3
votes
2 answers

Bash Tilde Expansion

Is it possible to add to the rules that bash uses for tilde expansion? I'd like to have ~data expand to /data/users/me, ~scratch expand to /data/scratch/me etc.. Is this possible, or does bash have too tight a tight hold on the '~'? Thanks, Andrew
ajwood
  • 18,227
  • 15
  • 61
  • 104
3
votes
1 answer

Haskell get a specific user's home directory path

I want to make a function to expand names of the form ~user with that user's home directory (usually /home/user/), including ~root, which is typically /root/. I know of the getHomeDirectory method, to get the current user's home, but I don't know of…
Zoey Hewll
  • 4,788
  • 2
  • 20
  • 33
3
votes
1 answer

tilde expansion when evaluating $PATH

On my system* cd # move to home mkdir tempdir PATH="$PATH:~/tempdir" # put tempdir in path touch tempdir/tempscript echo -e '#!/bin/bash\necho h' > tempdir/tempscript #…
Chris Middleton
  • 5,654
  • 5
  • 31
  • 68
3
votes
2 answers

Tilde (~/) not working on if then statement in Shell script

I have the following script file=${file:-letsdump.sh} checkfile="~/mysql_backup/$file" if [ -e "$checkfile" ]; then mv ~/mysql_backup/$file ~/mysql_backup/$file-bak-$(date +%d%m%Y_%H%M).bak else echo 'file doesnt exist' fi I know my file is…
brentwpeterson
  • 162
  • 2
  • 9
3
votes
2 answers

What means tilde in windows file pattern

I have pattern to search. Say "*.txt". Now I have some files I do not want to list there. I believe they do not match this pattern. But on windows, they do. I know tilde character is used to make short form of legacy 8.3 filename. That is…
Pihhan
  • 813
  • 5
  • 11
2
votes
2 answers

Tilde Expansion Doesn't Work When I Logged Into GUI

I'm using Ubuntu 11.10 and I have a strange problem. I have a few exports in my .profile file: export ANDROID_SDK_ROOT=~/workspace/android-sdk-linux_x86 export ANDROID_NDK_ROOT=~/workspace/android-ndk-r7 etc... However, when I log on into GUI, open…
Brian Park
  • 2,557
  • 22
  • 21
2
votes
1 answer

Unable to test whether a file exists in Bash

Consider the following Bash script: function dosomething { local fname="~/.bash_profile" if [[ -f "$fname" ]]; then echo "proceeding" else echo "skipping" fi } dosomething I always get "skipped" although I know that…
Nikolay Dutchuk
  • 683
  • 2
  • 6
  • 11
2
votes
3 answers

Bash tilde not expanding in certain arguments, such as --home_dir=~

Bash is not expanding the ~ character in the argument --home_dir=~. For example: $ echo --home_dir=~ --home_dir=~ Bash does expand ~ when I leave out the hyphens: $ echo home_dir=~ home_dir=/home/reedwm Why does Bash have this behavior? This is…
Reed
  • 35
  • 4