0

Example:

# echo $PATH
/home/admin*:*/bin

I assume it's a wildcard of some sort, but is it one level deep, or many?

For example, will */bin match only items in usr/bin or will it also match deeper items in usr/local/bin and /home/admin/bin? And will /home/admin* match /home/administrator and everything under it, also at multiple levels?

1
  • If this belongs in the Unix & Linux StackExchange site, please let me know how I can migrate it over.
    – Matt Woelk
    Commented Dec 7, 2015 at 14:59

2 Answers 2

7

What does asterisk (*) mean in a unix $PATH?

# echo $PATH
/home/admin*:*/bin

It means you have an invalid $PATH.

$PATH does not support wildcards.

2

This other answer states your $PATH is invalid, but I disagree.

That's because, in bash at least, it won't cause any errors - either when you set it, or when the shell tries to resolve a command via $PATH.

In $PATH, an asterisk means a literal * (asterisk).

That is, there is NO wildcard expansion performed, and it is actually checking the literal directory /home/admin*, which doesn't exist so it skips it, and it checks */bin, which is also similarly ignored.


You can create directories with a literal * in them (but... but... why?).
And, if done, then it will look there; eg, in the '*/bin' path

So, this would actually work with your given $PATH value:

cd /
mkdir \*
mkdir \*/bin
echo 'echo Hello from \"star\"/bin' > \*/bin/asterisk.bash
chmod 744 \*/bin/asterisk.bash

asterisk.bash

(If you want to try it out in a local directory instead of root, just don't cd into /)
(Not that I recommend doing this at home. Do it at a friend's house :-)

But since you probably did it anyway -- well, to get rid of the ridiculousness, the following three commands should do it.
(NB: I am not using rm -r just in case something gets mistyped or the shell you're in interprets things differently.)

rm \*/bin/asterisk.sh
rmdir \*/bin
rmdir \*
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .