LWN.net Logo

Advertisement

Front, Kernel, Security, Distributions, Development. See your byline here on LWN.net.

Advertise here

Recent behavior changes driving me nuts

Recent behavior changes driving me nuts

Posted Jul 4, 2006 7:54 UTC (Tue) by jzbiciak (✭ supporter ✭, #5246)
Parent article: CLI Magic: Using command history in the bash shell (Linux.com)

I know there are probably more "correct" ways to do this, but this is a long standing habit. I have a tendency to open a line with a # (thereby making it a comment) and then expanding out something in my history with !.

So, for example:

#!t

might expand out into

#tail -f /var/log/messages

I then up-arrow, remove the # and edit the line to my heart's content if it was the line I'm looking for. This works great w/ older bash, such as 2.05a. Recent bash versions, such as 3.1.17, don't seem to do this.

Does anyone know a way to reenable this in bash?


(Log in to post comments)

Recent behavior changes driving me nuts

Posted Jul 4, 2006 8:50 UTC (Tue) by abovett (subscriber, #13139) [Link]

If the histverify option (set with shopt) is set, you don't need to use the # trick. Any command you type using history expansion (with !) will be recalled to the prompt for checking and editing before it is executed - hit Return to execute it. In other words, if my history looks like:

540 cat SQ9285.txt
541 ls Documents/
542 history

and I type:

rm !540:1

and hit Return, then I get:

rm SQ9285.txt

with the cursor positioned at the end of the line.

Copyright © 2012, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds