3

I have a shell script named merge that takes a parameter that is a revision number. I usually invoke it merge 12345.

I would like to pass in zero parameters. The script should search my terminal output for the latest occurrence of the pattern /^Committed revision (\d+)\.$/ and use that value. However, I don't know how to search the terminal output, or indeed whether it is possible to do so.

4
  • 2
    It's not quite searching output directly; but how about recording terminal output (say, using shelr) and grepping the newest file created by that?
    – bertieb
    Jul 8 '15 at 14:42
  • That would be fine, but shelr in particular looks very heavyweight.
    – Thom Smith
    Jul 8 '15 at 15:24
  • 2
    Seems like it's one command (svn ?) in particular you're looking for the output from. Could you alias that to command | tee ~/commitlog.txt and then grep that file?
    – bertieb
    Jul 8 '15 at 16:40
  • 1
    Or if not, start your terminal session with zsh | tee ~/teminal.log for the whole thing (may be overkill). Or script ~/teminal.log for something similar; have to remember to invoke that though.
    – bertieb
    Jul 8 '15 at 16:42
1

Judging from the phrase Committed revision, it appears you are using svn. Rather than searching your terminal output for the revision number, you can just use

svn info -r HEAD

to get the latest revision number at the head of your repository. But you probably don't even need the revision number: You can just use HEAD itself directly in whatever you're trying to do.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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