This is a follow up to my thread: controlling grep output to file. I am working on the reply to that thread.
I started getting long winded then decided to make this succinct. Given a file of the basic format
Quote:
Searching for a123.sh
/home/users/repo/another.sh
/home/users/repo/a123.sh
/home/users/repo/.git/index
Searching for a456.sh
Etc
|
In that file I want to keep the first two lines.
The third one is to be deleted because it is a self reference. When the line ends with the searched for string it is to be deleted.
The fourth is to be deleted because it is within a git directory. Anything containing “.git” is to be deleted.
When the phrase “Searching for” is found, the filtering begins anew. There is a blank line before each “Searching for” phrase if that matters.
The question is: What is the best utility to implement this? Just point me in the right direction and I will see what I can discover.
RESOLVED
After writing a few test scripts and spending some time with awk I have decided that filtering the text file with awk is the best way to go.
Thank you for taking the time to read this question and posting replies.