0

In BASH I can normally start typing a file name, then type TAB and it will give me some suggestions.

I have a list of files that look like this:

20130519114000_add_hstore.rb
20130615125517_create_sites.rb
20130616112833_create_delayed_jobs.rb
....

Is there a way I could type something like "*delayed" and then TAB (or something) to find "20130616112833_create_delayed_jobs.rb".

At the moment, sifting through those numbers at the start of the filenames is too much cognitive load :)

5
  • did you try using something like ls | grep delayed or ls *delayed*? Commented Jun 17, 2013 at 4:02
  • Excellent, had not tried *delayed* - this works very well thanks :) Commented Jun 17, 2013 at 4:06
  • Make a reply and I will mark it as the solution, if you like Commented Jun 17, 2013 at 4:06
  • or ls "*delayed*" ? .... Commented Jun 17, 2013 at 4:13
  • @user537339: added this as answer per your request. Commented Jun 17, 2013 at 4:28

2 Answers 2

2

Yes. The details can vary depending on your keyboard, and your Readline command bindings, and how you're logged into the system, and so on, but typically you can do this by typing *delayed, and then hitting Alt+g instead of TAB. (Search for glob-complete-word in §8.4.8 "Some Miscellaneous [Readline] Commands" in The Bash Reference Manual.)

Sign up to request clarification or add additional context in comments.

1 Comment

+1. BTW, on some terminals prefix-meta (ESC) works well if Alt cannot be used.
1

You can use either:

ls *delayed*

or

ls | grep delayed

to filter list of files to what you want.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.