Text processing tools and/or languages

Little Girl littlergirl at gmail.com
Fri Jan 21 04:26:38 UTC 2022


Hey there,

Chris Green wrote:

>Yes, but it's *not* how sed and awk work. :-)
>
>Both sed and awk feed the whole of the text past each line of the
>script in turn, they don't process the text file line by line.  You
>don't have a concept of "where you are in the text" as you progress
>down your program.

How about a Bash one-liner using sed with a pipe?

sed -n '/Category/,$p' yourfile.txt | sed '0,/^$/{//d}'

The first command takes your file as input and prints nothing while
looking for the specified pattern (Category), then prints from the
first line matching the pattern to the end of the input. Then the
output of that command is piped to another sed command that removes
only the first blank line from the input and prints the output to the
terminal window.

I'm not well-versed in sed, but just playing around because I love
text manipulation. Someone more experienced could probably do all that
with one sed command and no pipe.

-- 
Little Girl

There is no spoon.




More information about the ubuntu-users mailing list