Re: Using history command in bash script



On Fri, Feb 24, 2012 at 01:59:39PM +0100, Johnny Rosenberg wrote:
Den 24 februari 2012 13:12 skrev Johnny Rosenberg <gurus.knugum@xxxxxxxxx>:
Seems not to be possible.

~$ cat > pa
#!/bin/bash

history
history
history
<Ctrl+d>
~$ chmod +x pa
~$ pa
~$

So there seem to be no history entries available when I run history
from a bash script. Why is this?

I also tried to use the ~/.bash_history file, but it doesn't seem like
events are added to it for each command executed, since at least a
couple of ten commands are missing at the end. Seems like things are
added to the .bash_history file ”now and then”, I'm not sure how
often. How can I get around this? Where are the latest history lines
recorded before they are added to the actual .bash_history file?

I'm trying to make a bash script that creates an alias for my last
command and save it in my .bash-aliases file (which is launched from
the .bashrc file), so I need some way to know what my latest command
was.


Kind regards

Johnny Rosenberg
ジョニー・ローゼンバーグ

About that .bash_history file:
At the moment, my history is 620 entries. If I look in the
.bash_history file, the last command there match entry 527 of the
history command's output. Where are the 93 missing entries? Can I
force bash to write those to the .bash_history file?
Yes, set history -a in your .bashrc


Kind regards

Johnny Rosenberg
ジョニー・ローゼンバーグ

--
ubuntu-users mailing list
ubuntu-users@xxxxxxxxxxxxxxxx
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users

--
ubuntu-users mailing list
ubuntu-users@xxxxxxxxxxxxxxxx
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users


Relevant Pages

  • [TOOL] ComLog.pl, a WIN32 Command Prompt Logger
    ... administrator to keep a history of commands typed in the DOS command ... prompt and the associated output, for example on an IIS server. ... # This program captures the input/output of the Windows NT Command Promt ... sub getcurrentdrive ...
    (Securiteam)
  • Release : ComLog 1.0, a WIN32 command prompt logger
    ... a WIN32 command prompt logger ... DOS sessions on Windows NT/2K (should also work on XP, ... This tool can be used by administrator to keep a history of commands ... typed in the DOS command prompt and the associated output, ...
    (Focus-IDS)
  • [Full-Disclosure] Release : ComLog 1.0, a WIN32 command prompt logger
    ... a WIN32 command prompt logger ... DOS sessions on Windows NT/2K (should also work on XP, ... This tool can be used by administrator to keep a history of commands ... typed in the DOS command prompt and the associated output, ...
    (Full-Disclosure)
  • Re: Need ideas: automating history dump
    ... > shell's history once a day, or whenever the shell exits normally ... zsh sessions will all have their history lists added to the ... history file, in the order they are killed. ... command line, setting this option will cause the oldest history ...
    (comp.unix.shell)
  • Re: address bar hijack
    ... trying to figure out command prompt which I find very obtuse to understand. ... "Robert Aldwinckle" wrote: ... >> love this feature, however, many websites I am looking for are international ... > search of History, type Folder. ...
    (microsoft.public.windows.inetexplorer.ie6.browser)