The Cookie Machine - Click here to drag window

DUMMY TEXT - Real text set in assets/js/theCookieMachine.js

Views: 8,830     Votes:  3 
Tags: command-line   bash  
Link: 🔍 See Original Answer on Ask Ubuntu 🔗

Title: Why can't I cd to a quoted tilde ('~')?
ID: /2018/05/08/Why-can_t-I-cd-to-a-quoted-tilde-__~___
Created: May 8, 2018
Upload: November 24, 2022    Layout:  post
TOC: false    Navigation:  false    Copy to clipboard:  false

Explore using echo command

The easiest way of exploring how things work in bash is with the echo command. In the case of ~ use this:

$ echo ~
$ echo '~'
$ echo "~"
$ echo `~`
bash: /home/rick: Is a directory

As you can see, when you single quote or use double quotes around ~ it is interpreted literally as a string and not expanded as a variable. When you use backticks (`) it is executed as a command and generates an error message.

⇧ Benchmarking a HDD using the Benchmark utility in "Disks" on Ubuntu 16.04 What system monitoring tools are available?  ⇩