I want to ask bash how it would complete a string as if I had typed it in a shell and hit tab. For example, if I type
I see the list of files and dirs in / that could possibly complete the ls command. How do I ask bash how it would complete 'ls /' without typing it and hitting tab? I want something like:
query_complete 'partial command line string'
I read the man page for complete and compgen, but couldn't figure out how to do it with them.
Note: 'ls /' is not the actual command I'm interested in, just an example. I am looking for a general solution for any arbitrary string representing a partial command line.