How can I execute a series of commands from my bash history? For instance if I want to execute the commands numbered 34 to 42 in my bash history, I've tried things like:
for n in $(seq 34 42); do
exec \!$n;
done
but that doesn't really it do the the trick, does it. Any ideas?
Thanks!
The best I can think of is something like this. Basically you pipe history into awk which prints lines with a number in a certain range. The results are passed to a sub-shell.
Somewhat based on this question.
Unfortunately, it seems that History (and the equivalent fc command) is disabled in scripting. I haven't found any documentation as to why though, the closest being the tldp page explaining History and Bash.