Pete Pete - 1 year ago 94
Linux Question

Save Commands Typed To Use later

I'm looking for something that is like this:

$ startmem
$ command1
$ command2
$ command3
$ endmem

Later, I want to call it like this:
, which executes the commands.

To clear, just use
again. Is there a way to to this?

Answer Source

You could do this:

startmem () { eval "mem() { $(sed '/^endmem/Q'); }"; }

That will take your input, up to but not including the "endmem" line, and generate a "mem" function.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download