Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 159579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T10:53:03+00:00 2026-05-11T10:53:03+00:00

Scenario: You are doing your daily Bash shell stuff. You want to run a

  • 0

Scenario:

You are doing your daily Bash shell stuff. You want to run a previous command so you type:

history | grep foocommand 

Then you get a list of all the foocommand stuff you did for however long your history has kept track, in a list like so:

  585 foocommand --baz --bleet   750 foocommand | grep quux   987 history grep | foocommand 

You decide you want to run command 585, so you type

  !585 

Question: Just for curiosity, is there a way to take that final step out of the equation and still get the expected outcome? It would be nice if there were a way to say:

 'grep through history and automatically run the first item on the list' 

or

'grep through history and let me choose which item to run using the arrow keys' 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T10:53:03+00:00Added an answer on May 11, 2026 at 10:53 am

    The syntax

    !foo 

    will run the last command that began with foo.

    Failing that, bash uses the readline library for input, which supports the history-search-forward and history-search-backward commands that can be bound to keys of your choice. I’ve edited my ./inputrc file to bind them to F8 and Shift-F8, so that they work like Windows’ equivalent feature in the console when I connect with PuTTY:

    '\e[19~':history-search-backward '\e[32~':history-search-forward 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My particular scenario involves doing some text transformation using regular expressions within a private
I am doing Internet Scenario for Plant Maintenance(PM) module. In that I have to
For my first question, I have your typical web e-com scenario where the user
I have a scenario where a class called Comment references an abstract type called
Using Git with Xcode (4.3) is a real nightmare. Here's a scenario... I want
I want to know your thoughts in performance and memory. Let's say I have
I am trying to wrap my head around doing validation in a MVC scenario.
I have a scenario where multiple users will be doing import processes, but all
Folks, I'd like to get your opinions on the following scenario. Most screens on
Scenario : I'll try to put an analogy with the loan broker example from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.