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?

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
    thank you, i read the text, but I misunderstood it – sharkant May 16 '17 at 20:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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