shell - Does the `hash` builtin command in Bash has an `-l` option? - Stack Overflow

时间: 2025-01-06 admin 业界

I am teaching myself the shell and enjoying it a lot. I came across the hash builtin the other day in a course and did some study on it. This led me to the bash manual, and namely this section on the builtin: link with highlight

The highlighted part is quite interesting and somehow indicates that at one point, the hash built in was supposed to print its internal hash table in a manner that can be automatically parsed:

The -l option causes output to be displayed in a format that may be reused as input. If no arguments are given, or if only -l is supplied, information about remembered commands is printed.

However, the command hash -l does not seem to work and there is no mention of this anywhere. LLM's also seem to say that -l is not a valid option for the builtin.

Below is a screenshot from the same manual in which the syntax of the builtin also mysteriously does not show the option described in the text just below it: A screenshot of the syntax line of the hash builtin

My question is whether this is an upcoming feature or a past feature of the builtin that was later removed.

There is not practical application, I am just learning and asking for the sake of science and learning.

According to the manual, the command hash -l should show the hash table used to lookup commands in the bash shell.