简体   繁体   中英

How to bookmark most using linux command line

How i can bookmark my custom command line in linux (centos 6.2)?

I'm using history | grep keyword history | grep keyword and then !command number now.

But is there any faster solution?

只需使用别名:

alias lala="ls -lrt|grep a"

Yes. You can define an alias , a function, or write a script in your bin folder.

Most shell's provides more complex history expansion. For example you can use

!?str

in zsh, bash etc. to execute the most recent command that contains str .

Another possibility to save keystrokes would be to use the incremental search of the history if you want a broader control over what you want to select.

To search the history backwards this feature is usually bound to <ctrl>-r , for forward search it's <ctrl>-s (at least in bash and zsh).

Just put a comment tag on it and you can search for the tag latter.

$ my-command # tag-bookmark-1

Then later you can grep or search history for tag-bookmark-1. Use something shorter if you would like. (I can't say about !, because I always use export histchars="")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM