Reputation: 3
I'd like to do the thing below:
To achieve step 2, what commands should be used?
commandA && lastcommand=<some skillful commands> && echo '$lastcommand was executed successfully!'
Upvotes: 0
Views: 95
Reputation: 781210
bash
doesn't have anything that does this automatically.
Instead of trying to get the command, put it into a variable and execute that variable.
lastcommand=(commandA arg1 arg2 arg3) && "${lastcommand[@]}" && echo "${lastcommand[@]} was executed successfully"
Upvotes: 2