18.22 Redo Last Command


Print last command:

$ !!:p

Suppose we have a complex previous perl command. We want to repeat it but for a different file.

$ perl -pi.bak -e 's|^\*\*(\d{8})\*\* |`r#cite_date($1)` |' cha_110_*.Rmd ; meld cha_110_*.Rmd.bak cha_110_*.Rmd
$ !perl:gs/110/140/
perl -pi.bak -e 's|^\*\*(\d{8})\*\* |`r#cite_date($1)` |' cha_140_*.Rmd ; meld cha_140_*.Rmd.bak cha_140_*.Rmd

An alternative is:

$ ^110^140^

And another:

$ fc -s 110=140

Your donation will support ongoing availability and give you access to the PDF version of this book. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Popular open source software includes rattle, wajig, and mlhub. Hosted by Togaware, a pioneer of free and open source software since 1984. Copyright © 1995-2022 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0