Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Dave00

macrumors 6502a
Original poster
Dec 2, 2003
886
119
Pittsburgh
I am looking for an app (or suggested LLM) that would take a large block of text and trim sections out of it based on certain strings. So, take the text, remove text from string A until you see string B, then string C until you see string D, etc. Doesn't need to do any formatting or anything. Bonus if it can also find text and then send sequences of keyboard entries following that text.

I have the full version of Keyboard Maestro and the free version of BBEdit, would be willing to buy the full version of that if it were capable of doing what I'm asking.

As an alternative, I might be able to ask one of the AI LLM's to do the same thing, but there's so many of them out there and apps that are based off of them that I'm unclear on where to get started.

Thanks in advance.
Dave
 
I’m sticking with the basics. If I am not mistaken it does not look like something that can not be done with the good old sed command.
grep, sed, awk, cut, sort, tr - tools (combined with regex) that can make the magic happen.

sed '/START_MARKER/,/END_MARKER/d' input.txt > output.txt

sed '/start_pattern/,/end_pattern/d' filename

Note that the patterns must be exactly the same like the string A, string B, string C, string D, etc.
And try it before using it! You can ask any LLM to help you with your specific needs. Good luck!

A little test:
$ cat test.txt
a
b
c
d
e
f
g
h
i
j
k
l
m
no
p
q
r
s
t

$ sed '/d/,/k/d' test.txt > test2.txt
$ cat test2.txt
a
b
c
l
m
no
p
q
r
s
t

$ sed '/d/,/p/d' test.txt > test3.txt
$ cat test3.txt
a
b
c
q
r
s
t
 
Last edited:
Pretty sure you can get one of the LLM's to give you back a script, program or commands which can do what you ask, but you'll have to provide a very specific prompt containing your description of the algorithm or program behavior along with example "large block of text" followed by example expected output. Something akin to ...

"Write a [pick your language] program which will [provide your description of algorithm or behavior]. Here is example input text: [large block of text] and here is example program expected output: [expected output]"
 
Thank you to both answers. Any suggestions on a LLM app for Mac? When i look for ChatGPT it just gives me apps based on ChatGPT.

Regarding command-line tools, I'm assuming that's within the Terminal app? And would there be a way to have it use whatever's in the copy pasteboard rather than a file? Essentially I want to be able to highlight some text, pass it to the converter, and then get back the finished text. I can do the highlighting and copying through Keyboard Maestro.

If start_pattern above is a particular string of text, do I format it as
sed '/"string1"/,/"string2"/d' start.txt > end.txt
or is there some other formatting?

Thanks again.
Dave
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.