Skip to main content

Timeline for History command inside bash script

Current License: CC BY-SA 3.0

6 events
when toggle format what by license comment
Jul 5, 2022 at 13:57 comment added TamaMcGlinn @Eric I've heavily modified your script until it finally works as expected (here you go). Try ls; date; scriptit lsdate 2 and see that vim opens with those two commands. However, not going to post it here as it doesn't actually answer this question.
Jul 5, 2022 at 12:43 comment added TamaMcGlinn This is a really interesting idea, although the posted implementation has a fatal flaw; as soon as you set -o history, it starts appending all further commands in this script to your history. That means that when you actually try script.sh task 3 it will give you the same 3 commands from inside script.sh itself every time! The solution is of course to just tail the file directly, rather than calling set -o history.
Jan 7, 2016 at 3:03 comment added Ken Sharp histtest.sh: 5: set: Illegal option -o history
Nov 23, 2015 at 4:16 review Late answers
Nov 23, 2015 at 4:25
Nov 23, 2015 at 4:06 review First posts
Nov 23, 2015 at 4:16
Nov 23, 2015 at 3:58 history answered Eric CC BY-SA 3.0