[ale] cut

Jerry Z. Yu z.yu at ptek.com
Mon Mar 11 09:21:09 EST 2002


	I'd use tr to sqash the consecutive spaces to one space.
	please note the first space counts too.

	history 1000 |	tr -s " " | cut -d " " -f3-



On Sat, 9 Mar 2002, Geoffrey wrote:

#
#
#Keith Hopkins wrote:
#> David S. Jackson wrote:
#>
#>> Hi
#>>
#>> I'm trying to come up with a command line that takes the shell's
#>> history and cuts everything after the first space, uniq -c's it,
#>> then sorts by which commands appear the most.  The idea is to
#>> tell you which commands appear most in your history and by how
#>> much.
#>>
#>> Something like:  history 1000 | cut ?? | uniq -c | sort
#>>
#>>
#>> What I'm having trouble with is the cut switch that removes
#>> everything after the first space.
#>>
#>> I've tried cut -d' ' -f1, but it doesn't work for some reason.
#>>
#>> Any ideas out there?
#>>
#>> TIA!
#>>
#>>
#>
#> "cut" just doesn't seems to cut it, so....
#>
#> history 1000 | awk '{print $2}' | sort | uniq -c | sort -nr | head
#
#more on this later as I'm headed out.  $2 is going to only give you the
#second field, I beleive he wants $2-$n, which can be done in awk with a
#for loop.
#
#instead of 'sort | uniq'   try sort -u which saves a piped process.
#
#>
#> note: uniq - remove duplicate lines from a SORTED file
#> you get very different results if you don't sort before the uniq.
#>
#> Lost in Tokyo,
#>   Keith
#>
#>
#>
#> ---
#> 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.
#>
#>
#
#
#--
#Until later: Geoffrey		esoteric at 3times25.net
#
#I didn't have to buy my radio from a specific company to listen
#to FM, why doesn't that apply to the Internet (anymore...)?
#
#
#---
#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.
#

Jerry Z. Yu					+1-404-262-8544 (O)
Systems Engineer				z.yu at ptek.com
IS Support, Voicecom,				www.voicecom.com
A business unit of PTEK Holdings, Inc.		www.ptek.com


---
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