On 1 sep. 2012, at 00:11, Jim Walker <tvcne...@gmail.com> wrote:

> I'm not 100% clear what you mean by BBedit worksheet.
> 
> I see there is a script editor option with some sort options there. 
> Would be cool if there was a sort and number dupes.

1) File > New > Shell Worksheet
If you've never used it, this should open a worksheet with some default 
examples.

2) Type 

osascript -e 'tell application "BBEdit" to get contents of text document 1' | 
tr '\r' '\n' | sort | uniq -c | bbedit --clean

into the worksheet.

3) Open the log-file in BBEdit, make sure it is the frontmost text document.
4) go back to the shell worksheet and select the line you just typed.
5) press 'enter' (⌅) or 'command+return' (⌘+⏎).

A new text document should open with the unique lines, prepended with the 
number of occurrences.
Of course, you could use the terminal, but this worksheet can be saved and 
reused. 

The command can be broken up into:

# ask BBEdit to dump the contents of text window 1 to 'standard output'
osascript -e 'tell application "BBEdit" to get contents of text document 1' 

# BBEdit uses \r internally, while a unix toolchain expects \n. tr translates:
tr '\r' '\n'

# sort the lines
sort

# find all unique entries. uniq requires its input to be sorted.
uniq -c

# Open the result in a new window in BBEdit.
bbedit --clean


The shell can be very powerful, with many tools that can be strung together in 
ways that even Bare Bones can't imagine.

Now a few things would be nice: 

a) an option for the BBEdit commandline tool to dump the contents of a 
specified window to stdout, including file-based line endings (see tr).
b) Adding a unique count to the unique lines/sort routine.

I'll file a feature request

Maarten

-- 
-- 
You received this message because you are subscribed to the 
"BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to bbedit@googlegroups.com
To unsubscribe from this group, send email to
bbedit+unsubscr...@googlegroups.com
For more options, visit this group at
<http://groups.google.com/group/bbedit?hl=en>
If you have a feature request or would like to report a problem, 
please email "supp...@barebones.com" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>



Reply via email to