简体   繁体   中英

Bash tab completion like ncftp?

In ncftp tab completion only shows the differences of matched files. Eg with the following files

file123 file125 aa

then typing ls fil will first complete to ls file12 and show

3 5 

Question

Can the same be done in Bash?

BASH supports tab-completion which is fairly robust. It is implemented through bash_completion . However, be aware that the way bash_completion is configured will depend on what options are set by default by your distribution. As for its basic functionality, it is exactly as you describe for ncftp . When a partial name is entered on the command line and tab is pressed, then a list of name-matched files are displayed. Once you have entered enough characters to make the name unique, tab will complete entry of the unique filename on the command line.

Linux also provides ls , but its behavior is not the same as you describe for ncftp . ls will return the names of files and directories that match the pattern you specified. By default, the name you provide to ls is not expanded. Meaning if you have file123 and file125 in a directory and issue the command ls file , you will be greeted by the error ls: cannot access bash: No such file or directory . But providing a wildcard (filename globbing) with ls file* will return both names.

If you have additional specific questions. Just leave a comment and we will do our best to help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM