0

All paths to directories with Linux commands are stored within a variable called $PATH. Once a command is being called its path is stored additionally in a notebook called hash to speed up the look up next time.

The hash is a shell builtin command and help hash gives a very short description. One option -t is described as printing all paths collected within the hash, and so I typed:

hash -t 

being sure I would get a listing of the hash's content.

However I got this:

bash: hash: -t: option requires an argument

  • What argument does it require?

  • What am I doing wrong?

  • How to show the content of the hash table?

1 Answer 1

3

This is hash as implemented in bash, I presume?

hash -t requires an argument, because it's a request for the hashed location of one or several utilities:

$ hash -t ls /bin/ls $ hash -t ls man ls /bin/ls man /usr/bin/man 

As the help text says:

print the remembered location of each NAME, preceding each location with the corresponding NAME if multiple NAMEs are given

To show all hashed utilities, use hash without any arguments:

$ hash hits command 1 /usr/bin/man 2 /bin/ls 

Again, as the help text says:

If no arguments are given, information about remembered commands is displayed.

1
  • 1
    thank you, i read the text, but I misunderstood it Commented May 16, 2017 at 20:56

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.