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
0
votes
2 answers

ASP.NET ~ Resolving

I have an asp.net application that has various text files it needs to load into a memory cache at start up. They are email body templates. I have them as files in my project in Visual studio, (with File.ReadAllText) but when I try to load them it is…
0
votes
1 answer

How to use `~` inside a double quote path reference

This command will cause an error wc -l "~/tmp.txt" wc: '~/tmp.txt': No such file or directory While these command running fine wc -l ~/tmp.txt 14 /home/user/tmp.txt wc -l "/home/user/tmp.txt" 14 /home/user/tmp.txt What is the difference? Can I do…
Sinh Nguyen
  • 4,277
  • 3
  • 18
  • 26
0
votes
1 answer

Trying to create a scp command in bash

I am trying to create a simple bash script that takes paths to directories as input and plugs them into an scp command. The scp command looks like this: scp user@server.com:/path/to/directory/on/server /path/to/directory/on/local/machine I have…
megamence
  • 335
  • 2
  • 10
0
votes
0 answers

Using scp: "No such file or directory" when scripting BASH

I wrote a script that would zip a folder and then store it another. So far this is working great. But now I want to send it using scp. I want to use eval so I can change them easily. But when I use it to send the file to some destination it always…
user11783767
0
votes
0 answers

Giving relative address as an input to read in bash scripts

I'm a beginner in bash scripting, Sorry if my question is a little bit like a noob. I wrote a scripts to create a configuration and save it to the directory which is taken from the user. the problem is that the scripts is not working when I enter…
lutube
  • 35
  • 3
0
votes
2 answers

Bash - Error parsing ~ in environment variable

I have environment variable export MY_WORK_DIR="~/project". While I'm using below command, it give me an error: realpath $MY_WORK_DIR realpath: '~/project': No such file or directory In my guess, the ~ is not processed while using this env…
Dorr
  • 577
  • 1
  • 8
  • 22
0
votes
2 answers

No such file or directory when we define the path as '~/path/to/csv' in postgres

lease=# COPY dhcpd_data (ip_address, start_time, end_time, mac_address, machine_name) FROM '~/outputcsvre.csv' DELIMITER ',' CSV HEADER; ERROR: could not open file "~/outputcsvre.csv" for reading: No such file or directory if i define the path as…
0
votes
1 answer

Tilde not expanded when quoting on the right hand side of a Bash variable assignment

I have made a directory ~/test_myDir I then run the following bash script: x="myDir" dirName="~/test_$x" cd $dirName echo "hey" > test.txt I get the following error: test.sh: line 5: cd: ~/test_myDir: No such file or directory I then remove the…
0
votes
3 answers

How to replace the home directory with a tilde? Linux

I'm currently making a shell in C++ and I've been able to output the absolute directory as the prompt with getcwd(), however when the user reaches the home directory I would like to output a tilde instead of the home directory. So for example…
Tomm
  • 127
  • 6
0
votes
0 answers

Tild and minus operators in php

I have found this line of code: for(;1<$argn/=++$x;);echo~$argn As an answer on code golf. I googled about tild symbol, and I found it's 2`complement. So if it's like that why not simply use the - symbol. If they aren't equal symbols so what is…
jahly
  • 3
  • 5
0
votes
2 answers

Overwritten HOME Variable

I recently learned that ~ refers to the HOME variable. So, if I set HOME=/foo and then try to use a bash script that would like to cd ~/Documents it ends up saying: foo/Documents: No such file or directory What's best practice in this situation?…
Ryan Farber
  • 343
  • 1
  • 4
  • 11
0
votes
2 answers

Bash Script - No file exist in ~/.ssh/

I'm trying to copy a file from: ~/.ssh/ but everytime I run the script it keeps saying pi@raspberrypi:/etc/greenwich $ ./copybash.sh cat: ~/.ssh/testfilegen2.log: No such file or…
spbr
  • 23
  • 6
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
  • 9,376
  • 15
  • 62
  • 109
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
  • 807
  • 1
  • 12
  • 24
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
  • 146
  • 1
  • 2
  • 10