2

This question already has an answer here:

If I am correct, pwd is a command, PWD is a variable('s name), and - in cd - is an operand.

What are the types of ~, ~-, ~+, * when they mean $HOME, the previous visited dir, the current dir, and the files under current dir? (from programming languages' perspective)

Are they variables' names? If yes, why does echo $~ not work?

Why does * work in:

for i in *; do ls "$i"; done

marked as duplicate by jasonwryan, Anthon, Jenny D, bsd, peterph Oct 16 '14 at 12:17

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1

* is a metacharacter (or wildcard), all the other ones are tilde-prefix examples (~ is standard, ~+ and ~- are extensions).

None are variables so there is no point prefixing them with a $.

echo $~ works fine, it displays $~. There is no expansion because ~ is not used as a prefix.

for i in *; ... works as designed.

Not the answer you're looking for? Browse other questions tagged or ask your own question.