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'
55 questions
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
  • 23,768
  • 8
  • 66
  • 93
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
  • 15,375
  • 15
  • 54
  • 90
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
  • 3,400
  • 2
  • 16
  • 30
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
  • 807
  • 4
  • 11
3
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
  • 407
  • 4
  • 17
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,297
  • 19
  • 21
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
2
votes
1 answer

Can't use folder path with tilde in rmdir

I need to be able to remove a directory that is relative to the Documents folder of any user's system. rmdir: ~/Documents/Folder: No such file or directory If I manually enter the expanded path (/Users/ricky/Documents/Folder), it works fine. I…
Ricky
  • 2,915
  • 21
  • 31
2
votes
2 answers

combining tilde expansion with variable substitution in bash

Say I'm running bash as root, and I want to chown the home directory of a user ada. Say also that ada is stored in a variable called $USER (because I'm doing this from a script). When I tried the following, chown -R $USER:$USER ~$USER the shell…
2
votes
1 answer

When does the slash in a Linux path need to be outside quotes in a bash script

Why does the first expansion not work, yet the second does? I know tilde has to be expanded outside quotes but the slash also had to be outside, unexpectedly. #!/bin/bash ls ~"/Documents/bashscripts/test.sh" ls ~/"Documents/bashscripts/test.sh"
H2ONaCl
  • 8,715
  • 11
  • 56
  • 100
1
vote
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
  • 5,291
  • 9
  • 40
  • 85
1
vote
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
  • 643
  • 2
  • 6
  • 11
1
vote
0 answers

Bash hangs in Cygwin on tilde-number

I encountered some bizarre Bash behavior today, and maybe it's a bug that's since been fixed, but I'm going to ask about it anyway. I have an x64 Cygwin install on my work computer with Bash 4.3.46 in it. By accident today, instead of typing !533…
Sean Werkema
  • 3,386
  • 1
  • 27
  • 36
1
vote
1 answer

Can't use tilde (~) for sed -i backup character on OSX: "sed: rename(): Not a directory"

On my OSX machine, I can't use ~ as the backup character for in-place sed. Any other character is fine. The error I get is... cryptic: rename(): Not a directory. Example: $ echo foo > bar $ sed -i ~ -e s/foo/hello/ bar sed: rename(): Not a…
hraban
  • 1,360
  • 15
  • 25
1
vote
1 answer

R: Is there a way to specify TMPDIR in .Renviron based on $HOME or ~?

I am looking for a simple student-proof way to specify a custom TMPDIR in R sessions. R seems unable to expand ~ or $USER, so if I simply write TMPDIR=~/tmp or TMPDIR=$HOME/tmp in .Renviron it does not find the folder, and uses /tmp instead, which…
ggll
  • 903
  • 9
  • 12