Terminal: Expand list of similar filename shortcutTerminal shortcut keyGetting the “Created” timestamp of a PDF file in the CLIAny way to list similar commands?How to see available commands that end with a certain string?Problem with spaces in file namesUbuntu: how to expand/minimize terminal window by a keymap?How to list my active shortcut keys

Why do the Romance languages use definite articles, when Latin doesn't?

Employer says they want Quality & Quantity, but only pays bonuses based on the latter

Why do some web servers still provide information on vendor and version in the HTTP response headers

A pencil in a beaker of water

Create a box using the tcolorbox package or any other? (image)

Covering an 8x8 grid with X pentominoes

Does the UA Blade Mastery feat stack with itself?

Why am I getting the wrong IP from DNS lookups?

Plain Hunt Bell-Ringing

Fiducial placement

Why are Buddhist concepts so difficult?

What happened to the SEV instruction on the 6502?

Avoid showing cancel button on dialog

What's the short and accented note at the very end of a song called?

What does "crank old Sabbath" refer to?

Merge numbers to a new number and find digit on position (n)

What would you do? Different results than what is reported

Moisture leaking out of chip in floor tile

What could an alternative human-powered transportation method look like?

What can players do while waiting for a troll to regenerate?

How to answer to the "We do not want to create any precedent" argument in salary negotiation?

Did the Allies reverse the threads on secret microfilm-hiding buttons to thwart the Germans?

Is there a name for the phenomenon of false positives counterintuitively outstripping true positives

LeetCode 65: Valid Number (Python)



Terminal: Expand list of similar filename shortcut


Terminal shortcut keyGetting the “Created” timestamp of a PDF file in the CLIAny way to list similar commands?How to see available commands that end with a certain string?Problem with spaces in file namesUbuntu: how to expand/minimize terminal window by a keymap?How to list my active shortcut keys






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;









4

















I remember reading a trick in a stackoverflow comment somewhere for getting a list of filenames in the terminal, but I can't exactly remember it.



If you have a bunch of files like:



foo-a.txt
foo-b.txt
foo-c.txt


There is a trick that goes something along the lines of:



  1. type cat foo-*

  2. Press something like tab, backspace, esc (this does not work, but is the step I want to know)

  3. The command line should now have cat foo-a foo-b foo-c

Note that is is different to the basic tab completion which shows a list of filenames below the command. This will put all the filenames in the command input so that pressing "enter" will execute cat with all the files.



Can anyone enlighten me?










share|improve this question


































    4

















    I remember reading a trick in a stackoverflow comment somewhere for getting a list of filenames in the terminal, but I can't exactly remember it.



    If you have a bunch of files like:



    foo-a.txt
    foo-b.txt
    foo-c.txt


    There is a trick that goes something along the lines of:



    1. type cat foo-*

    2. Press something like tab, backspace, esc (this does not work, but is the step I want to know)

    3. The command line should now have cat foo-a foo-b foo-c

    Note that is is different to the basic tab completion which shows a list of filenames below the command. This will put all the filenames in the command input so that pressing "enter" will execute cat with all the files.



    Can anyone enlighten me?










    share|improve this question






























      4












      4








      4


      0






      I remember reading a trick in a stackoverflow comment somewhere for getting a list of filenames in the terminal, but I can't exactly remember it.



      If you have a bunch of files like:



      foo-a.txt
      foo-b.txt
      foo-c.txt


      There is a trick that goes something along the lines of:



      1. type cat foo-*

      2. Press something like tab, backspace, esc (this does not work, but is the step I want to know)

      3. The command line should now have cat foo-a foo-b foo-c

      Note that is is different to the basic tab completion which shows a list of filenames below the command. This will put all the filenames in the command input so that pressing "enter" will execute cat with all the files.



      Can anyone enlighten me?










      share|improve this question

















      I remember reading a trick in a stackoverflow comment somewhere for getting a list of filenames in the terminal, but I can't exactly remember it.



      If you have a bunch of files like:



      foo-a.txt
      foo-b.txt
      foo-c.txt


      There is a trick that goes something along the lines of:



      1. type cat foo-*

      2. Press something like tab, backspace, esc (this does not work, but is the step I want to know)

      3. The command line should now have cat foo-a foo-b foo-c

      Note that is is different to the basic tab completion which shows a list of filenames below the command. This will put all the filenames in the command input so that pressing "enter" will execute cat with all the files.



      Can anyone enlighten me?







      command-line bash shortcut-keys






      share|improve this question
















      share|improve this question













      share|improve this question




      share|improve this question








      edited Feb 3 at 8:45







      mdsimmo

















      asked Feb 3 at 8:17









      mdsimmomdsimmo

      436 bronze badges




      436 bronze badges























          2 Answers
          2






          active

          oldest

          votes


















          5


















          1. Type cat foo-*

          2. Press Ctrl+X then * (asterisk/star) to expand the glob

            • If that doesn't work, run bind -p | grep glob-expand-word and check if it says "C-x*": glob-expand-word. If not, you can set it:

              bind '"C-x*": glob-expand-word'



          3. The command line should now be cat foo-a.txt foo-b.txt foo-c.txt



          glob-expand-word vs insert-completions



          OP's answer is about insert-completions (Esc, * or Alt+*), which is similar but different to glob-expand-word:




          • glob-expand-word expands filename globs.


          • insert-completions inserts all the possible completions that pressing Tab would show.

          So that means you can also use insert-completions for things besides filenames, like options. For example type ls --f, press Esc, *, and you will get ls --file-type --format=, though I'm not sure how useful that is.



          And that means that it behaves differently when expanding globs. For example if you type cat foo-* and press Esc, *, it will expand to only the first completion: cat foo-a.txt.






          share|improve this answer




























          • Thanks, that it! Btw: You can also use esc instead of ctr+x

            – mdsimmo
            Feb 3 at 8:59






          • 1





            @mdsimmo Esc, * is a different function actually. I just checked bind -p | grep '\e*' and it says "e*": insert-completions. I'm not clear on the exact difference, but if you type cat * then press Esc, *, it will expand to just the first matching item.

            – wjandrea
            Feb 3 at 9:02



















          2


















          I found the original comment here. (Can someone with more points upvote him for me? :P)



          The sequence is:



          • Type cat foo-

          • Press esc

          • Press * (asterisk)

          The same sequence seems to work with any program (not just cat)






          share|improve this answer























          • 1





            Upvoted the comment per request :p (BTW, worth noting that comment upvotes don't count towards reputation points)

            – wjandrea
            Feb 3 at 22:16






          • 1





            Alt+* also works (Alt+Shift+8 on a US keyboard). And in general any terminal shortcut that uses Esc, key can also be typed as Alt + key.

            – wjandrea
            May 29 at 20:50













          Your Answer








          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "89"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );














          draft saved

          draft discarded
















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1115192%2fterminal-expand-list-of-similar-filename-shortcut%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown


























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          5


















          1. Type cat foo-*

          2. Press Ctrl+X then * (asterisk/star) to expand the glob

            • If that doesn't work, run bind -p | grep glob-expand-word and check if it says "C-x*": glob-expand-word. If not, you can set it:

              bind '"C-x*": glob-expand-word'



          3. The command line should now be cat foo-a.txt foo-b.txt foo-c.txt



          glob-expand-word vs insert-completions



          OP's answer is about insert-completions (Esc, * or Alt+*), which is similar but different to glob-expand-word:




          • glob-expand-word expands filename globs.


          • insert-completions inserts all the possible completions that pressing Tab would show.

          So that means you can also use insert-completions for things besides filenames, like options. For example type ls --f, press Esc, *, and you will get ls --file-type --format=, though I'm not sure how useful that is.



          And that means that it behaves differently when expanding globs. For example if you type cat foo-* and press Esc, *, it will expand to only the first completion: cat foo-a.txt.






          share|improve this answer




























          • Thanks, that it! Btw: You can also use esc instead of ctr+x

            – mdsimmo
            Feb 3 at 8:59






          • 1





            @mdsimmo Esc, * is a different function actually. I just checked bind -p | grep '\e*' and it says "e*": insert-completions. I'm not clear on the exact difference, but if you type cat * then press Esc, *, it will expand to just the first matching item.

            – wjandrea
            Feb 3 at 9:02
















          5


















          1. Type cat foo-*

          2. Press Ctrl+X then * (asterisk/star) to expand the glob

            • If that doesn't work, run bind -p | grep glob-expand-word and check if it says "C-x*": glob-expand-word. If not, you can set it:

              bind '"C-x*": glob-expand-word'



          3. The command line should now be cat foo-a.txt foo-b.txt foo-c.txt



          glob-expand-word vs insert-completions



          OP's answer is about insert-completions (Esc, * or Alt+*), which is similar but different to glob-expand-word:




          • glob-expand-word expands filename globs.


          • insert-completions inserts all the possible completions that pressing Tab would show.

          So that means you can also use insert-completions for things besides filenames, like options. For example type ls --f, press Esc, *, and you will get ls --file-type --format=, though I'm not sure how useful that is.



          And that means that it behaves differently when expanding globs. For example if you type cat foo-* and press Esc, *, it will expand to only the first completion: cat foo-a.txt.






          share|improve this answer




























          • Thanks, that it! Btw: You can also use esc instead of ctr+x

            – mdsimmo
            Feb 3 at 8:59






          • 1





            @mdsimmo Esc, * is a different function actually. I just checked bind -p | grep '\e*' and it says "e*": insert-completions. I'm not clear on the exact difference, but if you type cat * then press Esc, *, it will expand to just the first matching item.

            – wjandrea
            Feb 3 at 9:02














          5














          5










          5









          1. Type cat foo-*

          2. Press Ctrl+X then * (asterisk/star) to expand the glob

            • If that doesn't work, run bind -p | grep glob-expand-word and check if it says "C-x*": glob-expand-word. If not, you can set it:

              bind '"C-x*": glob-expand-word'



          3. The command line should now be cat foo-a.txt foo-b.txt foo-c.txt



          glob-expand-word vs insert-completions



          OP's answer is about insert-completions (Esc, * or Alt+*), which is similar but different to glob-expand-word:




          • glob-expand-word expands filename globs.


          • insert-completions inserts all the possible completions that pressing Tab would show.

          So that means you can also use insert-completions for things besides filenames, like options. For example type ls --f, press Esc, *, and you will get ls --file-type --format=, though I'm not sure how useful that is.



          And that means that it behaves differently when expanding globs. For example if you type cat foo-* and press Esc, *, it will expand to only the first completion: cat foo-a.txt.






          share|improve this answer
















          1. Type cat foo-*

          2. Press Ctrl+X then * (asterisk/star) to expand the glob

            • If that doesn't work, run bind -p | grep glob-expand-word and check if it says "C-x*": glob-expand-word. If not, you can set it:

              bind '"C-x*": glob-expand-word'



          3. The command line should now be cat foo-a.txt foo-b.txt foo-c.txt



          glob-expand-word vs insert-completions



          OP's answer is about insert-completions (Esc, * or Alt+*), which is similar but different to glob-expand-word:




          • glob-expand-word expands filename globs.


          • insert-completions inserts all the possible completions that pressing Tab would show.

          So that means you can also use insert-completions for things besides filenames, like options. For example type ls --f, press Esc, *, and you will get ls --file-type --format=, though I'm not sure how useful that is.



          And that means that it behaves differently when expanding globs. For example if you type cat foo-* and press Esc, *, it will expand to only the first completion: cat foo-a.txt.







          share|improve this answer















          share|improve this answer




          share|improve this answer








          edited May 29 at 21:04

























          answered Feb 3 at 8:56









          wjandreawjandrea

          10.3k4 gold badges33 silver badges70 bronze badges




          10.3k4 gold badges33 silver badges70 bronze badges















          • Thanks, that it! Btw: You can also use esc instead of ctr+x

            – mdsimmo
            Feb 3 at 8:59






          • 1





            @mdsimmo Esc, * is a different function actually. I just checked bind -p | grep '\e*' and it says "e*": insert-completions. I'm not clear on the exact difference, but if you type cat * then press Esc, *, it will expand to just the first matching item.

            – wjandrea
            Feb 3 at 9:02


















          • Thanks, that it! Btw: You can also use esc instead of ctr+x

            – mdsimmo
            Feb 3 at 8:59






          • 1





            @mdsimmo Esc, * is a different function actually. I just checked bind -p | grep '\e*' and it says "e*": insert-completions. I'm not clear on the exact difference, but if you type cat * then press Esc, *, it will expand to just the first matching item.

            – wjandrea
            Feb 3 at 9:02

















          Thanks, that it! Btw: You can also use esc instead of ctr+x

          – mdsimmo
          Feb 3 at 8:59





          Thanks, that it! Btw: You can also use esc instead of ctr+x

          – mdsimmo
          Feb 3 at 8:59




          1




          1





          @mdsimmo Esc, * is a different function actually. I just checked bind -p | grep '\e*' and it says "e*": insert-completions. I'm not clear on the exact difference, but if you type cat * then press Esc, *, it will expand to just the first matching item.

          – wjandrea
          Feb 3 at 9:02






          @mdsimmo Esc, * is a different function actually. I just checked bind -p | grep '\e*' and it says "e*": insert-completions. I'm not clear on the exact difference, but if you type cat * then press Esc, *, it will expand to just the first matching item.

          – wjandrea
          Feb 3 at 9:02














          2


















          I found the original comment here. (Can someone with more points upvote him for me? :P)



          The sequence is:



          • Type cat foo-

          • Press esc

          • Press * (asterisk)

          The same sequence seems to work with any program (not just cat)






          share|improve this answer























          • 1





            Upvoted the comment per request :p (BTW, worth noting that comment upvotes don't count towards reputation points)

            – wjandrea
            Feb 3 at 22:16






          • 1





            Alt+* also works (Alt+Shift+8 on a US keyboard). And in general any terminal shortcut that uses Esc, key can also be typed as Alt + key.

            – wjandrea
            May 29 at 20:50
















          2


















          I found the original comment here. (Can someone with more points upvote him for me? :P)



          The sequence is:



          • Type cat foo-

          • Press esc

          • Press * (asterisk)

          The same sequence seems to work with any program (not just cat)






          share|improve this answer























          • 1





            Upvoted the comment per request :p (BTW, worth noting that comment upvotes don't count towards reputation points)

            – wjandrea
            Feb 3 at 22:16






          • 1





            Alt+* also works (Alt+Shift+8 on a US keyboard). And in general any terminal shortcut that uses Esc, key can also be typed as Alt + key.

            – wjandrea
            May 29 at 20:50














          2














          2










          2









          I found the original comment here. (Can someone with more points upvote him for me? :P)



          The sequence is:



          • Type cat foo-

          • Press esc

          • Press * (asterisk)

          The same sequence seems to work with any program (not just cat)






          share|improve this answer
















          I found the original comment here. (Can someone with more points upvote him for me? :P)



          The sequence is:



          • Type cat foo-

          • Press esc

          • Press * (asterisk)

          The same sequence seems to work with any program (not just cat)







          share|improve this answer















          share|improve this answer




          share|improve this answer








          edited Feb 3 at 22:15









          wjandrea

          10.3k4 gold badges33 silver badges70 bronze badges




          10.3k4 gold badges33 silver badges70 bronze badges










          answered Feb 3 at 8:55









          mdsimmomdsimmo

          436 bronze badges




          436 bronze badges










          • 1





            Upvoted the comment per request :p (BTW, worth noting that comment upvotes don't count towards reputation points)

            – wjandrea
            Feb 3 at 22:16






          • 1





            Alt+* also works (Alt+Shift+8 on a US keyboard). And in general any terminal shortcut that uses Esc, key can also be typed as Alt + key.

            – wjandrea
            May 29 at 20:50













          • 1





            Upvoted the comment per request :p (BTW, worth noting that comment upvotes don't count towards reputation points)

            – wjandrea
            Feb 3 at 22:16






          • 1





            Alt+* also works (Alt+Shift+8 on a US keyboard). And in general any terminal shortcut that uses Esc, key can also be typed as Alt + key.

            – wjandrea
            May 29 at 20:50








          1




          1





          Upvoted the comment per request :p (BTW, worth noting that comment upvotes don't count towards reputation points)

          – wjandrea
          Feb 3 at 22:16





          Upvoted the comment per request :p (BTW, worth noting that comment upvotes don't count towards reputation points)

          – wjandrea
          Feb 3 at 22:16




          1




          1





          Alt+* also works (Alt+Shift+8 on a US keyboard). And in general any terminal shortcut that uses Esc, key can also be typed as Alt + key.

          – wjandrea
          May 29 at 20:50






          Alt+* also works (Alt+Shift+8 on a US keyboard). And in general any terminal shortcut that uses Esc, key can also be typed as Alt + key.

          – wjandrea
          May 29 at 20:50



















          draft saved

          draft discarded















































          Thanks for contributing an answer to Ask Ubuntu!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1115192%2fterminal-expand-list-of-similar-filename-shortcut%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown









          Popular posts from this blog

          Tamil (spriik) Luke uk diar | Nawigatjuun

          Align equal signs while including text over equalitiesAMS align: left aligned text/math plus multicolumn alignmentMultiple alignmentsAligning equations in multiple placesNumbering and aligning an equation with multiple columnsHow to align one equation with another multline equationUsing \ in environments inside the begintabularxNumber equations and preserving alignment of equal signsHow can I align equations to the left and to the right?Double equation alignment problem within align enviromentAligned within align: Why are they right-aligned?

          Where does the image of a data connector as a sharp metal spike originate from?Where does the concept of infected people turning into zombies only after death originate from?Where does the motif of a reanimated human head originate?Where did the notion that Dragons could speak originate?Where does the archetypal image of the 'Grey' alien come from?Where did the suffix '-Man' originate?Where does the notion of being injured or killed by an illusion originate?Where did the term “sophont” originate?Where does the trope of magic spells being driven by advanced technology originate from?Where did the term “the living impaired” originate?