Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Let's say I use CTRL-R and then type tail to find the last time I ran tail.

What comes up is tail -F /path/to/log/file-2011-03-07.log

The command I want to run is the above command, but with 2011-03-08 instead of 2011-03-07. Is there a way to do replace with a regexp via the command line?

share|improve this question

1 Answer 1

r 7=8 tail should do it. Read up on fc and r; they're not very widely known but very useful for this kind of thing.

There isn't regexp editing directly, but if you use fc directly you may be able to play with fc -e a bit. (Indeed, fc -e 'sed -ie s/foo/bar/' command appears to work. You might be able to wrap that in a function.) There's also -m to use a shell glob to select the command from history.

share|improve this answer
    
Your answer directed me zshexpn(1) where I was able to find out that I could do something like this: !tail:s/6/7 Which kind of does what I want. Will take a look at r, fc and zshexpn(1) more to see what is possible! –  emostar Apr 7 '11 at 1:44

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.