printing ksh history a la csh

Lawrence V. Cipriani lvc at cbnews.att.com
Wed Feb 13 10:00:50 AEST 1991


In article <2582 at sapwdf.UUCP> Bill Wohler <wohler at sap-ag.de> writes:
>folks,
>
>  in ksh, i'd like to say "history 30" to print the last 30 commands as
>  in csh.  if you know how to do this, i would be obliged.

	$ history -30

>  another "feature" of our ksh is that if you specify a starting
>  number that is too low, instead of printing just what it knows,

This has been a sore point with me for a long time as well.  I have
asked Korn to change ksh so that it would do this but it was not done.

You could do something like this:

	ncmd="`history -1 | sed -e 's/[ 	].*//' -e 1d`"
	if [ "$ncmd" -gt "$HISTSIZE" ]
	then
		ncmd=$HISTSIZE
	fi
	history -$ncmd

That's the basic idea at least.
-- 
Larry Cipriani, att!cbvox!lvc or lvc at cbvox.att.com
"Fight fire with fire, I always say" -- Bugs Bunny



More information about the Comp.unix.shell mailing list