<div dir="ltr">One aspect of history that I find useful is timestamps. On Red Hat-based distros (CentOS, fedora, RHEL, SLC...) bash history timestamps are disabled by default. I can't speak for other shells and distros. To enable them export the environment variable HISTTIMEFORMAT in your .bash_profile.<div>
<div><br></div><div>export HISTTIMEFORMAT="%F %T "</div></div><div>produces output like:<br></div><div><br></div><div><div>[tcr@case ~]# history | tail -3</div></div><div><div> 1003 2014-02-11 13:51:17 cat .bash_profile </div>
<div> 1004 2014-02-11 13:54:38 pwd</div><div> 1005 2014-02-11 13:54:40 history | tail -3</div></div><div><br></div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Feb 11, 2014 at 1:48 PM, Jim Wildman <span dir="ltr"><<a href="mailto:jim@rossberry.com" target="_blank">jim@rossberry.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Sure, if what you want is in the last few commands, and you just want to<br>
repeat that command. But say you need to redo the command, but change<br>
it slightly and it was 5 days ago? And note that I used the word<br>
efficient. ditto for use of vi or any other editor. There are better<br>
ways than uparrow, backspace, etc.<br>
<br>
And for the case of unreliable vpn...use screen on your destination,<br>
along with the other tips.<br>
<br>
Really my point is that there are MANY efficiency tools built into the<br>
*nix command line. If you spend any time at all administering systems,<br>
and especially if you get paid to do it, it pays to know them. If<br>
nothing else, it will put you miles ahead of the arrow key guys in the<br>
productivity department.<br>
<br>
On Tue, 11 Feb 2014, Steve VanSlyck wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
It's easier to press one arrow key a few times than to type out a command<br>
phrase.<br>
<br>
<br>
<br>
Jim Wildman <<a href="mailto:jim@rossberry.com" target="_blank">jim@rossberry.com</a>> wrote:<br>
<br>
With bash<br>
!?phrase<br>
will search for and execute that last command containg phrase<br>
history | grep apt (as others said) will find the command, with the<br>
command number in front<br>
!number will execute that command<br>
!number:s/oldphrase/newphrase/ will edit and then execute the command<br>
you can do similar things with the 'fc' command which will open your<br>
default editor with the given command. The command executes when you<br>
exit the editor.<br>
983 exit<br>
984 ls<br>
985 ls<br>
986 cd rossdev<br>
987 ls<br>
988 cat rbhosts.txt<br>
989 svn up<br>
990 exit<br>
991 scdr<br>
992 pine<br>
993 screen<br>
994 scdr<br>
995 scdr<br>
996 scdr<br>
997 exit<br>
998 scdr<br>
999 exit<br>
1000 scdr<br>
1001 man fc<br>
1002 history 20<br>
fc 988<br>
opens vi with "cat rbhosts.txt" in the buffer<br>
When I<br>
see someone who only uses the arrow keys, I know they have not<br>
gotten serious about efficient command line use.<br>
csh (sorry, no idea off the top of my head). <br>
<br>
Alternately, if you need a reason to use zsh, here's one more: you can typ<br>
e<br>
'apt' and then use the up arrow to reverse through full commands in your<br>
history that start with "apt".<br>
<br>
<br>
<br>
<br>
______________________________<u></u>______________________________<u></u>________________<br>
Jim Wildman, CISSP, RHCE <a href="mailto:jim@rossberry.com" target="_blank">jim@rossberry.com</a> <a href="http://www.rossberry.net" target="_blank">http://www.rossberry.net</a><br>
"Society in every state is a blessing, but Government, even in its best<br>
state, is a necessary evil; in its worst state, an intolerable one."<br>
Thomas Paine<br>
<br>
______________________________<u></u>______________________________<u></u>________________<br>
colug-432 mailing list<br>
<a href="mailto:colug-432@colug.net" target="_blank">colug-432@colug.net</a><br>
<a href="http://lists.colug.net/mailman/listinfo/colug-432" target="_blank">http://lists.colug.net/<u></u>mailman/listinfo/colug-432</a><br>
<br>
<br>
--<br>
Sent from Kaiten Mail. Please excuse my brevity.<br>
<br>
</blockquote>
<br>
------------------------------<u></u>------------------------------<u></u>----------<br>
Jim Wildman, CISSP, RHCE <a href="mailto:jim@rossberry.com" target="_blank">jim@rossberry.com</a> <a href="http://www.rossberry.net" target="_blank">http://www.rossberry.net</a><br>
"Society in every state is a blessing, but Government, even in its best<br>
state, is a necessary evil; in its worst state, an intolerable one."<br>
Thomas Paine<br>_______________________________________________<br>
colug-432 mailing list<br>
<a href="mailto:colug-432@colug.net">colug-432@colug.net</a><br>
<a href="http://lists.colug.net/mailman/listinfo/colug-432" target="_blank">http://lists.colug.net/mailman/listinfo/colug-432</a><br>
<br></blockquote></div><br></div>