Hello!

I would like to know how can I tell to count the number of -| (minus followed by a pipe with no space) expressions in one line using grep in a given file.

I tried grep /\-|\ |/ | filename wc -l but this does not seem to work well.
Thank you for your answer.

Regards
/Rob

Try this:

grep "\- \|" * |wc -l

Bye

Hello!

I would like to know how can I tell to count the number of -| (minus followed by a pipe with no space) expressions in one line using grep in a given file.

I tried grep /\-|\ |/ | filename wc -l but this does not seem to work well.

I think
echo "sdf -| qwe-|fgh-|fubar" | sed -e 's/-|/-|\n/g' a.a |grep -- "-|" |wc -l
should do and illustrate the trick. (Hint: try '--' before an argument that begins with a '-'; many GNU program understand '--' to mean 'end of options'.)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.