[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[SOLVED] Re: forcibly unmounting and bash history

First of all, why didn't post it to the list? Do you think it's too
OT? But, on the other hand, both your mails were no help and also
misleading. I'd like to elaborate on that. 

On Sun, Jul 06, 2003 at 06:51:29AM -0400, Robert August Vincent II wrote:
> "history" is a bash built-in.
> Bash runs differently depending on whether it was invoked as /bin/sh
> or /bin/bash.
> Try putting
> #!/bin/bash
> at the top of your shell script.
True, since I've forgotten another detail you could indeed as well
assume that I've forgotten about every other too. I have to say,
though, that was not the case. Simply put, I knew all that (plus
some more). Thanks anyway. 

On Sun, Jul 06, 2003 at 07:04:21AM -0400, Robert August Vincent II wrote:
> This little shellscript works...
> #!/bin/bash
> set -o history
> history | sed -e 's/^[[:blank:]]\+[0-9]\+[[:blank:]]\+//'
Allow me to add something -- your script works all right but doesn't
do what I (and, possibly, you as well) wanted. What was the output
of your script? Have you compared it with your actual history? Sorry
if I was not clear with my question, maybe it was misleading.
However, as I perceive it, your script will always print this and
this only (without the sed part): "1  history". Is it different at
your end?

I think not, since the script starts a new shell with only _one_
command in _its_ history: namely, "history". Do you already see the
correct solution? (Again, as it was with you, I can only assume that
you ran it as "/path/to/script/script". You didn't mention doing it
otherwise, so read on.)

Now try running it as "source /path/to/script/script" or ".
/.../script" and compare the output. That's better, isn't

I've sent the mail too quickly and forgot about this mistake. 

> But why, oh why, are you trying to run a command that reads from and
> writes to the same file?
> Running:
> cat .bash_history | perl -i -ne 'whatever...' > .bash_history
> doesn't do anything useful...

Again, please don't rush. You obviously haven't tested it.
Currently, my history shows 42 items, whereas the .bash_history file
only has 15. Why is that? The problem is that the history file only
gets updated when you log out. Try it out: check both, log out and
log in again. Thus when you issue "halt" or "reboot", your current
history will not be stored to that file. Making an alias, however,
could: "alias myownhalt='source /path/script;halt'". Do you still
think it's useless?

If I'm not mistaken, it's quite handy. So I hope we've both learned


echo ${girl_name} > /etc/dumpdates

Reply to: