Grep for search.

hi,
i got files delimited by |^ character. eg.

apple|^ball|^cat|^dog|^egg

i need to find if the above file contains | (pipe ) character inside the data.eg.

apple|^ball|^cat|^d|og|^egg

.

above file contains | character in the dog data. how can i search that.

Please use code tags as required by forum rules!

For your above question, try

$ grep -o "[^|^]\+[|][^^|]\+" file
d|og

Hi RudiC,

Could you please explain reg ex ?

Thanks
Pravin

[^|^]\+       one or more occurrences of any char not being ^ nor |.
[|]           exactly |; in square brackets so it's not interpreted as a regex OR.
[^^|]\+       same as above

To only detect if there are pipe symbols in the data this should suffice:

grep -E '\|([^^]|$)'

--
@RudiC: if a pipe symbol is the last character on the line it is also part of the data