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.

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
add comment

2 Answers

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
add comment

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
add comment

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.