[colug-432] Search Command History
Richard Hornsby
richardjhornsby at gmail.com
Tue Feb 11 08:44:05 EST 2014
On Feb 11, 2014, at 05:41 , Steve VanSlyck <s.vanslyck723 at gmail.com> wrote:
> It's easier to press one arrow key a few times than to type out a command phrase.
>
These are all excellent tips, many of which I had no idea existed. I always do history | grep foo, or try to arrow back, or if I’m feeling really brave using the bang prefix and hope I get lucky.
On a related note, one thing I’ve noticed is that the bash history doesn’t seem to be written to disk immediately. Even from within our office, we’re required to VPN into the datacenter before being able to log onto any hosts. The VPN isn’t the most stable thing in the world, nor the are wireless connections we have to use. (They recently moved us to a brand new building and decided during construction that wired connections for employees’ desks were an unnecessary expense.) It seems that when my connection gets dropped and the shell is pre-maturely terminated, all the history from that session is gone.
Is there something I’m missing that will cause this to get written more immediately than on a proper logout? I’ve run into several situations where I really needed to see that history to know what someone else was doing, or where I left off, or what that complex sed command was - but I’m out of luck.
> Jim Wildman <jim at rossberry.com> wrote:
>
> With bash
> !?phrase
> will search for and execute that last command containg phrase
>
> history | grep apt (as others said) will find the command, with the
> command number in front
>
> !number will execute that command
> !number:s/oldphrase/newphrase/ will edit and then execute the command
>
> you can do similar things with the 'fc' command which will open your
> default editor with the given command. The command executes when you
> exit the editor.
>
> 983 exit
> 984 ls
> 985 ls
> 986 cd rossdev
> 987 ls
> 988 cat rbhosts.txt
> 989 svn up
> 990 exit
> 991 scdr
> 992 pine
> 993 screen
> 994 scdr
> 995 scdr
> 996 scdr
> 997 exit
> 998 scdr
> 999 exit
> 1000 scdr
> 1001 man fc
> 1002 history 20
>
> fc 988
> opens vi with "cat rbhosts.txt" in the buffer
>
> When I
> see someone who only uses the arrow keys, I know they have not
> gotten serious about efficient command line use.
> csh (sorry, no idea off the top of my head).
>
> Alternately, if you need a reason to use zsh, here's one more: you can type
> 'apt' and then use the up arrow to reverse through full commands in your
> history that start with "apt".
>
>
>
>
>
>
>
> Jim Wildman, CISSP, RHCE jim at rossberry.com http://www.rossberry.net
> "Society in every state is a blessing, but Government, even in its best
> state, is a necessary evil; in its worst state, an intolerable one."
> Thomas Paine
>
>
> colug-432 mailing list
> colug-432 at colug.net
> http://lists.colug.net/mailman/listinfo/colug-432
>
> --
> Sent from Kaiten Mail. Please excuse my brevity.
> _______________________________________________
> colug-432 mailing list
> colug-432 at colug.net
> http://lists.colug.net/mailman/listinfo/colug-432
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.colug.net/pipermail/colug-432/attachments/20140211/dcc2e8ee/attachment.html
More information about the colug-432
mailing list