Using Grep or AWK to find all of the occurences of a specified string

0

I have a massive single line of data and I am trying to find the occurrences of a specified string. I then want to export the occurrences (-/+) 20 characters to another file. Can anyone offer a basic idea of how I would go about doing this?

Dan Smith

Posted 2014-06-16T21:15:56.613

Reputation: 1

2Grep and awk are both line oriented, so they'll both be awkward working with one long line. What OS is this? Could you give some more detail about the format of this data and the string that you're looking for? – Kenster – 2014-06-16T21:27:19.880

If the data file is huge, you should redefine the record separator. The answers to this similar question on unix.sx might be useful.

– Thor – 2014-06-16T22:27:26.047

Answers

0

Try using grep with the -o option.

That should list all matches to your provided regular expression on your long input line, one match per output line.

pbr

Posted 2014-06-16T21:15:56.613

Reputation: 1 285