Questions tagged [tilde]
The tilde tag has no usage guidance.
30
questions
0
votes
2
answers
619
views
What kind of language construct is the swung dash (tilde, ~)?
The swung dash can be used in place of the home directory. Depending on the current user it has a different value. In this sense it works like a variable.
Yet it is not a variable. I can't do echo $~...
0
votes
2
answers
392
views
Why do tilde prefixes expand prior to assignment, but braces don't
tl;dir
In bash, brace expansion occurs before tilde expansion. However, tilde prefixes seem to expand prior to variable assignment and brace expansion doesn't. Why?
Details and examples
Brace ...
3
votes
1
answer
706
views
What's the different between with a ~ and without a ~ in a string variable in Bash? [duplicate]
I'm using a dotfile manage software, named dotdrop. Using a config file named .env, contents like: git_folder="~/code/Git".
Also use a script to setup this dotfile tool before the first use of it, as ...
3
votes
2
answers
6k
views
Why do you have to put ~/ before .bashrc when opening the .bashrc file? [duplicate]
I'm wondering why it is required to put ~/ before .bashrc when opening the bashrc file.
To illustrate:
I normally open files on my system as follows:
vim filename.extension
But while in the /...
3
votes
4
answers
2k
views
Bash script copy file to user's (wildcard) home dir
I need to copy /root/nbu/file1.sh to every user's home directory if user's id is even number.
Trying to execute following script:
#!/bin/bash
cat /etc/passwd | while read LINE
do
username=$(awk -...
1
vote
1
answer
3k
views
How to save a path with ~ into a variable?
I have these variables in my script:
TARGET=username
TARGET_DIR="~${TARGET}/.ssh"
I want the TARGET_DIR var to hold this path: /home/username/.ssh but to use ~ instead of /home/.
But when I run the ...
0
votes
3
answers
2k
views
using tilde in variable from the user
I saw a lot of posts about it all over the internet but i couldn't make it run as i wanted.
I have an input from the user of a path. If the user will type ~/Desktop/ for example i can't use $ans in ...
0
votes
2
answers
264
views
I accidentally exited vim with :x!~ and now my ~ shows up in a different path
When exiting a file as root, I typed :x!~ and hit enter. Now I have the following:
root@host:/etc/shinken/services$ ll
total 64K
-rw-r--r-- 1 0 0 515 Sep 1 18:24 ~
drwxr-xr-x 2 10003 ...
15
votes
2
answers
8k
views
Expansion of tilde in zsh
I stumbled upon this behavior of zsh when using FreeBSD:
% dd if=/dev/zero bs=1M count=1 of=~/test2
dd: failed to open '~/test2': No such file or directory
This really confused me because the same ...
0
votes
1
answer
19k
views
chmod 400 command returning "No such file or directory" error. Trying to launch an instance through AWS
CODE:
root@crane-linux:/home/crane/Downloads# sudo chmod 400 ~/home/crane/Downloads/mykey.pem
chmod: cannot access '/root/home/crane/Downloads/mykey.pem': No such file or directory
root@crane-linux:/...
4
votes
1
answer
937
views
readlink literal vs variable
Using BASH: the answer is probably obvious but, not for me.
> echo $PWD
/root/fcm
> readlink -f ~
/root
> # but then with a variable or literal
> a='~'
> readlink -f $a
/root/fcm/~
>...
1
vote
4
answers
2k
views
Why is `mkdir ~root/.ssh` the same thing as `mkdir /root/.ssh`?
This is fairly trivial and I'm just curious as to why mkdir ~root/.ssh is the same thing as mkdir /root/.ssh? I'm reviewing the following docker file and the creator uses mkdir ~root/.ssh to create ...
3
votes
2
answers
1k
views
how to set tilde + alias style?
I noticed there's default tilde + alias exist:
[root@xiaobai ~]# cd ~[press Tab]
~abrt/ ~dbus/ ~lp/ ~openvpn/ ~root/ ~systemd-...
11
votes
4
answers
7k
views
Create another shortcut `~~` like `~` (home directory)
I want ~~ to point to a different directory so I can use it as a shortcut. I want it to have exactly same functionalities as ~. How can I do this?
3
votes
3
answers
2k
views
What is the difference of defining a variable with or without quotation marks? [duplicate]
If I define a variable with the quotation mark:
TEMP="~/Dropbox"
then
ls $TEMP
would not work, instead
echo $TEMP | ls
works.
And to get the same result, I can also define the variable without ...