Skip to main content

Questions tagged [tilde]

The tag has no usage guidance.

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 $~...
Blcknx's user avatar
  • 261
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 ...
De Novo's user avatar
  • 115
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 ...
roachsinai's user avatar
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 /...
MarkMark's user avatar
  • 583
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 -...
Ignas Poška's user avatar
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 ...
lakerda's user avatar
  • 355
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 ...
erans's user avatar
  • 123
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 ...
MrDuk's user avatar
  • 1,597
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 ...
UTF-8's user avatar
  • 3,287
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:/...
CulturedI Crane's user avatar
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/~ >...
fcm's user avatar
  • 447
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 ...
Ole's user avatar
  • 727
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-...
林果皞's user avatar
  • 5,206
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?
user avatar
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 ...
username123's user avatar

15 30 50 per page
1
2