Skip to main content

Timeline for History command inside bash script

Current License: CC BY-SA 3.0

10 events
when toggle format what by license comment
Sep 24, 2023 at 20:32 comment added Sergio Abreu This script added rubish to the screen. We just want to type less command using up and down arrows instead of typing commands... That's why is interesting to have subshell cmds in top history!!
Sep 24, 2023 at 20:24 comment added Sergio Abreu You left 3 dots ... in the code
Dec 18, 2017 at 8:22 history edited Gilles 'SO- stop being evil' CC BY-SA 3.0
added 223 characters in body
Dec 18, 2017 at 8:19 comment added Gilles 'SO- stop being evil' @nath That's what the question asked for. It is pretty much pointless, as I point out. Monitoring activity is a hard problem that shell history won't solve. If you're debugging a script then set -x is a lot more useful.
Dec 18, 2017 at 2:42 comment added nath the problem with this is that it adds all commands following set -o history to the history which is then going to be stuffed up with entries like if [... vars=$(... etc.
Mar 20, 2017 at 10:18 history edited CommunityBot
replaced http://superuser.com/ with https://superuser.com/
Jan 7, 2016 at 15:45 comment added Gilles 'SO- stop being evil' @KenSharp Yes it is. You obviously ran it under dash, given the error message. Bash does not have the error message Illegal option (it would say set: history: invalid option name).
Jan 7, 2016 at 12:36 comment added Gilles 'SO- stop being evil' @KenSharp That's because you tried to use it in an sh script (and your sh is dash juding by the exact wording of the error message). To access bash's history, you need to use bash (script starting with #!/bin/bash or #!/usr/bin/env bash).
Jan 7, 2016 at 2:56 comment added Ken Sharp This refuses to work in a script: histtest.sh: 5: set: Illegal option -o history
Jan 11, 2011 at 21:07 history answered Gilles 'SO- stop being evil' CC BY-SA 2.5