[ale] cut

Geoffrey esoteric at 3times25.net
Sat Mar 9 17:32:43 EST 2002




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.






More information about the Ale mailing list