[ale] history command in script

Charles Shapiro cshapiro at nubridges.com
Tue Mar 12 14:21:55 EST 2002


Yeh, you right. Another good way to do it is to insert it right into the
interactive shell as part of the environment. I tried this and it worked
fahn:

nameOfScript () {

echo "Do you want the full argument or just the base command?"
read answer


if echo $answer | grep -i y ; then
   history 1000 | tr -s " " | cut -d " " -f3- | sort | uniq -c |sort -r
| less
else
   history 1000 | cut -d' ' -f5 | sort | uniq -c | sort -r | less
fi
}

You can then invoke this by typing "nameOfScript".
The easy  way to do this is to create a script file with the above lines
in it,
->DON'T<- chmod +x  it, and run it from the ".". Leaving it
non-executable is to remind 
you not to run it by typing its name, which will simply create a
subshell containing the command which then immediately exits. 

Most k00l HAX04 D00Ds already have a "${HOME}/.envfile" for stuff like
this, which they run from the dot in their profile scripts. If you set
the "BASH_ENV" symbol to the envfile filename, then it will
automagically run for any sub-shells you spawn, so your routines are
available all the time.

-- CHS

-----Original Message-----
From: Fletch [mailto:fletch at phydeaux.org]
To: ale at ale.org
Sent: Tuesday, March 12, 2002 12:56 PM
To: ale at ale.org
Subject: Re: [ale] history command in script


>>>>> "David" == David S Jackson <deepbsd at earthlink.net> writes:

[...]


    David> But "history" doesn't seem to get executed.  Is that
    David> because it's a builtin?  Why should that make a difference?
    David> Is there another reason why "history" doesn't get executed?

        R'ing TFM, it looks like the `history' builtin isn't enabled
by default in non-interactive shells.  Look for the part about the
`set' command, specifically the part under `-o option-name'.  It
probably would work if you added `set -o history' before trying to
call the history command.


-- 
Fletch                | "If you find my answers frightening,
__`'/|
fletch at phydeaux.org   |  Vincent, you should cease askin'          \
o.O'
770 933-0600 x211(w)  |  scary questions." -- Jules
=(___)=
                      |                                               U

---
This message has been sent through the ALE general discussion list.
See http://www.ale.org/mailing-lists.shtml for more info. Problems
should be 
sent to listmaster at ale dot org.


---
This message has been sent through the ALE general discussion list.
See http://www.ale.org/mailing-lists.shtml for more info. Problems should be
sent to listmaster at ale dot org.






More information about the Ale mailing list