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
0
votes
1 answer

Bash script, returns awk: can't open file ~/.ssh/config

I'm able to awk this file directly from the command line but when I try to use it from my script it breaks. Not sure why. Heres my script #!/bin/bash ssh_config_path="~/.ssh/config" echo -n "Enter the username of the account you'd like to switch…
Daniel Kobe
  • 7,696
  • 11
  • 44
  • 94
0
votes
0 answers

~ not working from read command

I have a script where I am trying to have a user enter the PATH to a command. And most of the time, this command is going to live in the user directory, so more often than not, the PATH will be entered using the ~ sign. The code looks essentially…
Kenyon
  • 667
  • 1
  • 9
  • 23
0
votes
1 answer

bash - looping through directory

I'm having trouble looping through the files in a directory with bash. I'm quite new to bash and can't seem to figure out the issue that I'm having. When I loop through the files in a directory that I explicitly mention, there doesn't seem to be a…
Evan Cooper
  • 147
  • 1
  • 8
0
votes
1 answer

How to perform tilde expansion for multiple paths set in an environment variable?

The following tilde expansion works as expected. $ A=~/foo.txt $ echo $A /home/lone/foo.txt In the following case, tilde expansion does not work because the tildes are within quotes. $ A="~/foo.txt ~/bar.txt" $ echo $A ~/foo.txt ~/bar.txt I know I…
Lone Learner
  • 12,094
  • 14
  • 66
  • 159
0
votes
1 answer

Taking relative command line arguments... In Java

No I don't mean relative to project or working directory. I mean that the following command java -jar myJar.jar ~/ should provide a string with "/home/user"... This doesnt seem to be working as expected. I am passing the argument in via eclipse's…
0
votes
0 answers

How can tilde expansion be used to get a full path from Bash variable that uses tilde to represent a path?

Let's say I have the following variable set: directoryTrash="~/trash" How can I use this variable to create the directory it describes? I've tried using it with mkdir in the following way: mkdir -p "${directoryTrash}" When I do this, the directory…
d3pd
  • 6,679
  • 18
  • 56
  • 111
0
votes
0 answers

Tilde(~) in nginx.conf for relative path

I want to use the tilde (~) to point to the /home/user directory as I want to have relative paths in production, but doesn't seem to work in nginx.conf file, although it works fine with .ini files. Also tried $HOME and $(HOME) location / { …
theblackpearl
  • 966
  • 11
  • 33
0
votes
1 answer

Tilde prefix returns invalid home directory

I am trying to find the home directory of users on a UNIX (Solaris/AIX) box using echo ~username This does return the home directory for all valid users. For some reason this command also outputs home directory which are non-existent for few users…
thinkster
  • 506
  • 2
  • 5
  • 17
0
votes
2 answers

Cannot create directory with tilde

Given this script # cat foo.sh echo $HOME set -x mkdir ~ I am getting this result # ./foo.sh /home/Steven Penny ++ mkdir '' mkdir: cannot create directory `': No such file or directory If I run mkdir "$HOME" I have no problem. I think the issue is…
Steven Penny
  • 82,115
  • 47
  • 308
  • 348
0
votes
1 answer

How to search in fields delimited by the tilde character

I have a field in the database separated by tilde ~ I can't figure out how to search in the field with a mssql query. Ex select * from table where john in repnames Data is in the field like tom~john~max I've tried a few searches on Google but…
Kurt
  • 3
  • 1
  • 4
1 2 3
4