Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grep wilcard of unknown length In between pipes

Tags:

grep

I'm trying to grep the following string:

Line must start with a 15 and the rest of the string can have any length of numbers between the pipes. There must be nothing in between the last 2 pipes.

"15|155702|0101|1||"

So far i have:

grep "^15|" $CONCAT_FILE_NAME >> "VAS-"$CONCAT_FILE_NAME

I'm having trouble specifying any length of numbers when using [0-9]

like image 788
user3124205 Avatar asked Dec 10 '25 19:12

user3124205


1 Answers

You need to escape the |

grep -E '^15\|([[:digit:]]+\|)+\|$'
like image 67
iruvar Avatar answered Dec 14 '25 00:12

iruvar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!