Questions tagged [tilde]

25 questions
14
votes
1 answer

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 thing works just fine in bash. I can touch files…
UTF-8
  • 3,175
  • 5
  • 23
  • 50
13
votes
1 answer

Why tilde (~) doesn't expand when used with CLI argument starting with dash?

I lost a couple of hours trying to run VNC server (x0vncserver) and the client refused to connect with weird message that No password configured for VNC Auth The server also prints this error SVncAuth: opening password file '~/.vnc/passwd'…
Tihomir Mitkov
  • 363
  • 3
  • 9
11
votes
4 answers

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?
VarunAgw
  • 567
  • 4
  • 18
6
votes
1 answer

Command not found in zsh, but found in bash

I'm using zsh on ubuntu and I created a symlink for bat as so: ln -s /usr/bin/batcat /home/user_name/.local/bin/bat hitting ls -l from ~/.local/bin shows: lrwxrwxrwx 1 tux tux 15 May 19 13:47 bat -> /usr/bin/batcat Now from any directory(even…
Haris Muzaffar
  • 249
  • 2
  • 6
5
votes
1 answer

Tilde expansion vs. variables in Bash

Please, consider the following snippet: $ export xx=foo $ sudo bash -c 'echo $xx ~' /root Which is ok. We can't see xx. However, if I expose it: $ sudo -E bash -c 'echo $xx ~' foo /home/xropi Though many say ~ is not alias, somehow it's part of…
xropi
  • 73
  • 5
4
votes
1 answer

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/~ > readlink -f "~" /root/fcm/~ I'm expecting to receive just…
fcm
  • 427
  • 4
  • 15
3
votes
1 answer

What's the different between with a ~ and without a ~ in a string variable in Bash?

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
  • 306
  • 4
  • 16
3
votes
2 answers

Why do you have to put ~/ before .bashrc when opening the .bashrc file?

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 /home directory if I do the following: vim .bashrc…
MarkMark
  • 553
  • 1
  • 7
  • 16
3
votes
4 answers

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 -v var="$LINE" -F: '{ if ($3 % 2 == 0) …
3
votes
2 answers

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-network/ ~adm/ ~ftp/ …
林果皞
  • 4,946
  • 2
  • 29
  • 45
3
votes
3 answers

What is the difference of defining a variable with or without quotation marks?

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 the quotation mark, like: TEMP=~/Dropbox by doing…
username123
  • 149
  • 6
2
votes
2 answers

How does the tilde expansion work within a shell variable?

I came across something funny when testing my script. I can ls my directory from the shell manually if I run $ ls ~/db_backups/ test1 test2 $ However, if I assign a shell variable a dir location as such with the tilde, it doesn't work. I tried…
Classified
  • 483
  • 2
  • 7
  • 13
2
votes
0 answers

Multiple files with the same name and a tilde are written while editing a file with gvim

I am under fedora 29. I edit my files with gvim and since a few days, one of them appears multiple times, renamed with an additional letter and tilde. The directory looks like this : sf1.pdf sf1.tec~ sf1.tef~ sf1.tei~ sf1.tel~ sf1.teo~ …
Marc
  • 21
  • 1
2
votes
2 answers

The tilde key ("~") combination doesn't show up in bash

I am using an Acer Swift One laptop with Windows 10. The keyboard is a standard German keyboard. I downloaded bash today from git-scm.com/download/win and tried some commands. For some reason bash shows k instead of ~ when pressing the tilde…
Linda
  • 29
  • 1
  • 2
1
vote
2 answers

Tilde not returning home directory

After sudo command to change user, Tilde (~) not returning current user's home directory but returning previous login user's home directory. I needed to expand with echo ~USERNAME but I need to make echo ~ to keep compatibility existing…
1
2