Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've got a bunch of pdf files that are joined with a very long command line sitting in a directory. Some are in English and some are in French, differentiated by _e.pdf and _f.pdf.

Because they're joined in a specific order the command line can't be shortened, but I'd like to modify and re-execute it, simply replacing _e by _f. How can I use sed (or other) for this?

Let's say the command is

pdfjoin file1_e.pdf file2_e.pdf file3_e.pdf 

and in history it's command 10.

I've got as far as

echo !10 | sed 's/_e.pdf/_f.pdf/g'

which echoes the command I want to run. But I actually want to run that, not just display the command.

share|improve this question
up vote 5 down vote accepted

Have you tried backticks?

`echo !10 | sed 's/_e.pdf/_f.pdf/g'`

Though I can't help feeling that you should be using make.

share|improve this answer

By the way GNU sed has more interesting trick to execute commands:

echo !10 | sed 's/_e.pdf/_f.pdf/ge'
share|improve this answer

Your Answer


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.