Challenge - 5 Problems
Tab Completion Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate1:30remaining
What is the output of pressing Tab twice after typing 'ls /et'?
You type
ls /et in a Linux terminal and press the Tab key twice quickly. What will the shell display?Attempts:
2 left
💡 Hint
Think about how tab completion works when multiple matches exist.
✗ Incorrect
Pressing Tab twice after a partial path shows all possible completions starting with that prefix. Since '/etc/' is a directory starting with '/et', it will list it.
💻 Command Output
intermediate1:30remaining
What happens when you press Tab after typing a unique command prefix?
You type
pyth in a Linux terminal where only the command python3 starts with 'pyth'. What happens when you press Tab once?Attempts:
2 left
💡 Hint
Think about how tab completion behaves with only one possible match.
✗ Incorrect
If only one command matches the typed prefix, pressing Tab once completes it automatically.
📝 Syntax
advanced2:00remaining
Which command enables programmable tab completion for a custom script?
You want to add tab completion to your custom script named
mytool. Which command correctly loads bash completion for it?Attempts:
2 left
💡 Hint
Look for the bash built-in command that links a function to completion.
✗ Incorrect
The 'complete' command with -F option assigns a function to handle tab completion for a command.
🔧 Debug
advanced2:00remaining
Why does tab completion not work for your script?
You wrote a bash completion function for your script but pressing Tab does nothing. Which is the most likely cause?
Attempts:
2 left
💡 Hint
Think about how bash knows which function to call for completion.
✗ Incorrect
Without the 'complete' command linking the function to the script, bash won't use it for tab completion.
🚀 Application
expert2:30remaining
How to create a tab completion that suggests only files with '.txt' extension?
You want to write a bash completion function that suggests only files ending with '.txt' when pressing Tab after your command. Which snippet correctly generates this list?
Attempts:
2 left
💡 Hint
Use 'compgen -f' to list files and filter by extension.
✗ Incorrect
'compgen -f' lists files; piping to grep filters only '.txt' files for completion.