as far as i know all unix text processing utilities are reading one line at a time and performing one action on this line.I have a huge file with a single line of text which contains several tokens im concerned with.You can think of the content of the file as something like this:xzxzxzzxzxAxzzBxzxCzxxzxxzxzzxzxzAzBzxxxxzzCzxzxzxzxzxxzzI want to get the two strings between (A and B) and (B and C) for every occurrence of A.*B.*C.In this example my desired output would be this:xzz xzxz zxxxxzzHow do i do this?edit: sorry, i didn't make it clear. A, B and C are long Strings that can only be identified by regular expressions.
Searching a text file with a single line using regular expressions
command line;text processing
I'm sure there are many interesting answers using awk,perl,sed, and others.  Here is a rather simplistic options that uses tr to turn this problem back into one a problem that we know how to solve--finding a pattern within a line: $ tr 'C' '\n' <test.file | sed -n 's/.*A\(.*\)B\(.*$\)/\1 \2/p'The tr 'C' '\n' command translates any C in the input into a newline character.  Thus, it is then necessary to just pipe it into a command that will output the text between A and B and between B and the end of the line.If A, B, and C are regular expressions rather than simple characters, try:sed -e 's/C/\n/g' < test.file | sed -n 's/.*A\(.*\)B\(.*\)/\1 \2/p'This uses the same basic idea, but uses sed to create the newlines.