Terminal: Expand list of similar filename shortcut
Clash Royale CLAN TAG#URR8PPP
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:
- type
cat foo-*
- Press something like
tab
,backspace
,esc
(this does not work, but is the step I want to know) - 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
add a comment |
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:
- type
cat foo-*
- Press something like
tab
,backspace
,esc
(this does not work, but is the step I want to know) - 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
add a comment |
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:
- type
cat foo-*
- Press something like
tab
,backspace
,esc
(this does not work, but is the step I want to know) - 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
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:
- type
cat foo-*
- Press something like
tab
,backspace
,esc
(this does not work, but is the step I want to know) - 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
command-line bash shortcut-keys
edited Feb 3 at 8:45
mdsimmo
asked Feb 3 at 8:17
mdsimmomdsimmo
486
486
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
- Type
cat foo-*
- Press Ctrl+X then * (asterisk - Shift+8 on a US keyboard) to expand the glob
- That's the default shortcut. If it doesn't work, check
bind -p | grep glob-expand-word
to see if it's set as the default:"C-x*": glob-expand-word
. If it's not, you can set it withbind '"C-x*": glob-expand-word'
.
- That's the default shortcut. If it doesn't work, check
- 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, *), 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 it 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 what good that does...
And that means that it behaves differently when expanding filenames or globs. For example if you type cat foo-*
and press Esc, *, it will expand to only the first completion: cat foo-a.txt
.
Thanks, that it! Btw: You can also use esc instead of ctr+x
– mdsimmo
Feb 3 at 8:59
1
@mdsimmoEsc
,*
is a different function actually. I just checkedbind -p | grep '\e*'
and it says"e*": insert-completions
. I'm not clear on the exact difference, but if you typecat *
then pressEsc
,*
, it will expand to just the first matching item.
– wjandrea
Feb 3 at 9:02
add a comment |
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
)
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
add a comment |
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/3.0/"u003ecc by-sa 3.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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
- Type
cat foo-*
- Press Ctrl+X then * (asterisk - Shift+8 on a US keyboard) to expand the glob
- That's the default shortcut. If it doesn't work, check
bind -p | grep glob-expand-word
to see if it's set as the default:"C-x*": glob-expand-word
. If it's not, you can set it withbind '"C-x*": glob-expand-word'
.
- That's the default shortcut. If it doesn't work, check
- 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, *), 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 it 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 what good that does...
And that means that it behaves differently when expanding filenames or globs. For example if you type cat foo-*
and press Esc, *, it will expand to only the first completion: cat foo-a.txt
.
Thanks, that it! Btw: You can also use esc instead of ctr+x
– mdsimmo
Feb 3 at 8:59
1
@mdsimmoEsc
,*
is a different function actually. I just checkedbind -p | grep '\e*'
and it says"e*": insert-completions
. I'm not clear on the exact difference, but if you typecat *
then pressEsc
,*
, it will expand to just the first matching item.
– wjandrea
Feb 3 at 9:02
add a comment |
- Type
cat foo-*
- Press Ctrl+X then * (asterisk - Shift+8 on a US keyboard) to expand the glob
- That's the default shortcut. If it doesn't work, check
bind -p | grep glob-expand-word
to see if it's set as the default:"C-x*": glob-expand-word
. If it's not, you can set it withbind '"C-x*": glob-expand-word'
.
- That's the default shortcut. If it doesn't work, check
- 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, *), 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 it 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 what good that does...
And that means that it behaves differently when expanding filenames or globs. For example if you type cat foo-*
and press Esc, *, it will expand to only the first completion: cat foo-a.txt
.
Thanks, that it! Btw: You can also use esc instead of ctr+x
– mdsimmo
Feb 3 at 8:59
1
@mdsimmoEsc
,*
is a different function actually. I just checkedbind -p | grep '\e*'
and it says"e*": insert-completions
. I'm not clear on the exact difference, but if you typecat *
then pressEsc
,*
, it will expand to just the first matching item.
– wjandrea
Feb 3 at 9:02
add a comment |
- Type
cat foo-*
- Press Ctrl+X then * (asterisk - Shift+8 on a US keyboard) to expand the glob
- That's the default shortcut. If it doesn't work, check
bind -p | grep glob-expand-word
to see if it's set as the default:"C-x*": glob-expand-word
. If it's not, you can set it withbind '"C-x*": glob-expand-word'
.
- That's the default shortcut. If it doesn't work, check
- 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, *), 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 it 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 what good that does...
And that means that it behaves differently when expanding filenames or globs. For example if you type cat foo-*
and press Esc, *, it will expand to only the first completion: cat foo-a.txt
.
- Type
cat foo-*
- Press Ctrl+X then * (asterisk - Shift+8 on a US keyboard) to expand the glob
- That's the default shortcut. If it doesn't work, check
bind -p | grep glob-expand-word
to see if it's set as the default:"C-x*": glob-expand-word
. If it's not, you can set it withbind '"C-x*": glob-expand-word'
.
- That's the default shortcut. If it doesn't work, check
- 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, *), 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 it 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 what good that does...
And that means that it behaves differently when expanding filenames or globs. For example if you type cat foo-*
and press Esc, *, it will expand to only the first completion: cat foo-a.txt
.
edited Feb 3 at 22:40
answered Feb 3 at 8:56
wjandreawjandrea
9,26942663
9,26942663
Thanks, that it! Btw: You can also use esc instead of ctr+x
– mdsimmo
Feb 3 at 8:59
1
@mdsimmoEsc
,*
is a different function actually. I just checkedbind -p | grep '\e*'
and it says"e*": insert-completions
. I'm not clear on the exact difference, but if you typecat *
then pressEsc
,*
, it will expand to just the first matching item.
– wjandrea
Feb 3 at 9:02
add a comment |
Thanks, that it! Btw: You can also use esc instead of ctr+x
– mdsimmo
Feb 3 at 8:59
1
@mdsimmoEsc
,*
is a different function actually. I just checkedbind -p | grep '\e*'
and it says"e*": insert-completions
. I'm not clear on the exact difference, but if you typecat *
then pressEsc
,*
, 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
add a comment |
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
)
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
add a comment |
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
)
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
add a comment |
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
)
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
)
edited Feb 3 at 22:15
wjandrea
9,26942663
9,26942663
answered Feb 3 at 8:55
mdsimmomdsimmo
486
486
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
add a comment |
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
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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