imported>Anton-krom |
Jeff-strong (talk | contribs) m (Editorial review and minor corrections) |
||
Line 1: | Line 1: | ||
Very often, the shell can help us to complete file and directory names when we begin to type the name of a file (or directory) and then | Very often, the shell can help us to complete file and directory names when we begin to type the name of a file (or directory) and then press {{Key|TAB}}. Try it now. Type "cd M" and then press {{Key|TAB}}. The shell completes the rest of the name by appending "erlin" to what you've already typed. Then press {{Key|ENTER}}. Because the completion is not ambiguous (i.e., there is only one solution) the shell completes the name. If there were multiple possibilities, the shell would complete as much as possible and then beep. At this point, we could press {{Key|TAB}} twice in succession to see the possible completions. Let's try this. Within the Merlin directory, create three new directories: hello, hello2, and hello3: | ||
{{ConsoleLine|john-williams@codermerlin:~/Merlin$ |mkdir hello}} | {{ConsoleLine|john-williams@codermerlin:~/Merlin$ |mkdir hello}} | ||
Line 5: | Line 5: | ||
{{ConsoleLine|john-williams@codermerlin:~/Merlin$ |mkdir hello3}} | {{ConsoleLine|john-williams@codermerlin:~/Merlin$ |mkdir hello3}} | ||
Then, type | Then, type "cd h" as below: | ||
{{ConsoleLine|john-williams@codermerlin:~/Merlin$ |cd h}} | {{ConsoleLine|john-williams@codermerlin:~/Merlin$ |cd h}} | ||
Now, press {{Key|TAB}}. | Now, press {{Key|TAB}}. The shell completes as much of the name as possible and then beeps. (Depending on your terminal you might not hear the beep or you might see a flash.) | ||
{{ConsoleLine|john-williams@codermerlin:~/Merlin$ |cd hello}} | {{ConsoleLine|john-williams@codermerlin:~/Merlin$ |cd hello}} | ||
Now press {{Key|TAB}} twice in succession. The shell | Now press {{Key|TAB}} twice in succession. The shell displays matching possibilities and then provides a new prompt followed by the previous entry: | ||
{{ConsoleLine|hello/ hello2/ hello3/|}} | {{ConsoleLine|hello/ hello2/ hello3/|}} | ||
{{ConsoleLine|john-williams@codermerlin:~/Merlin$ |cd hello}} | {{ConsoleLine|john-williams@codermerlin:~/Merlin$ |cd hello}} | ||
You now have the option of pressing {{Key|ENTER}} to accept "hello" or adding some more characters (in this case | You now have the option of pressing {{Key|ENTER}} to accept "hello" or adding some more characters (in this case "2" to form "hello2" or "3" to form "hello3") and then pressing {{Key|ENTER}} to execute the command as-is or {{Key|TAB}} to search for additional completions. In our case, let's press {{Key|ENTER}} to go to the "hello" directory: | ||
{{ConsoleLine|john-williams@codermerlin:~/Merlin$ |cd hello}} | {{ConsoleLine|john-williams@codermerlin:~/Merlin$ |cd hello}} |
Latest revision as of 13:19, 22 February 2023
Very often, the shell can help us to complete file and directory names when we begin to type the name of a file (or directory) and then press TAB. Try it now. Type "cd M" and then press TAB. The shell completes the rest of the name by appending "erlin" to what you've already typed. Then press ENTER. Because the completion is not ambiguous (i.e., there is only one solution) the shell completes the name. If there were multiple possibilities, the shell would complete as much as possible and then beep. At this point, we could press TAB twice in succession to see the possible completions. Let's try this. Within the Merlin directory, create three new directories: hello, hello2, and hello3:
john-williams@codermerlin:~/Merlin$ mkdir hello
john-williams@codermerlin:~/Merlin$ mkdir hello2
john-williams@codermerlin:~/Merlin$ mkdir hello3
Then, type "cd h" as below:
john-williams@codermerlin:~/Merlin$ cd h
Now, press TAB. The shell completes as much of the name as possible and then beeps. (Depending on your terminal you might not hear the beep or you might see a flash.)
john-williams@codermerlin:~/Merlin$ cd hello
Now press TAB twice in succession. The shell displays matching possibilities and then provides a new prompt followed by the previous entry:
hello/ hello2/ hello3/
john-williams@codermerlin:~/Merlin$ cd hello
You now have the option of pressing ENTER to accept "hello" or adding some more characters (in this case "2" to form "hello2" or "3" to form "hello3") and then pressing ENTER to execute the command as-is or TAB to search for additional completions. In our case, let's press ENTER to go to the "hello" directory:
john-williams@codermerlin:~/Merlin$ cd hello
john-williams@codermerlin:~/Merlin/hello$