Apply Tags To Linux Commands To Easily Retrieve Them From History

13 Responses

  1. Experienced Admin says:

    And what’s the benefit of using additional software that doesn’t come out of the box and may not exist for every distribution instead of simply creating aliases?

  2. lie says:

    Rather than !?, it’s much easier to use Ctrl-R (reverse-i-search), which is also a standard feature that’s built into most shells. Ctrl-R gives you live preview of what will run during recall as you type, and you can modify the commands before running them as well.

  3. Just make an alias or script if it’s something you use a lot

  4. Charles Martin says:

    It would probably help if your example of how to tag commands actually including the tag

  5. Andrew says:

    Yes aliases are a way to do this as well but I love that there is another way to do this

  6. Cj says:

    you can just use alias’ to run the hard to remember commands, won’t need the !? Prefix

    For longer tasks that may need additional arguments/parameters, use a bash script…

  7. Deys says:

    Thanks for sharing. Cool technique!

  8. Experienced Admin says:

    I may not have read accurately how you proposed to do this, I apologize: It is indeed a neat trick. In any case, since I haven’t read past articles in which you may have mentioned this already, you may want to point out that aliases are a viable alternative, too.

  9. Bill says:

    Edit .bascrc and add an alias.

  10. Cool trick! Out of the box thinking in multiple ways 😉

    I addressed this issue by maintaining a repo of knowledge that I’ve found useful, but I can see how your trick here would be a great companion to that!

    I appreciate things that can be done without apt-get!

  11. James Birkett says:

    You can also use ctrl+r to search for the comment tag interactively, allowing you to edit the command before running it again, which is useful if you just need to change a parameter such an an IP address in a complex command.

  12. sk says:

    Good point. I will update this guide with your input. Thanks for pointing it out. Good day!!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.