I want to validate a file which contains multiple lines in this format:
alphanumeric_word_with_spaces|alphanumeric_word_with_spaces|alphanumeric_word_with_spaces|alphanumeric_word_with_spaces|alphanumeric_word_with_spaces|alphanumeric_word_with_spaces|alphanumeric_word_with_spaces
so basically, the line is pipe delimited and I need to check whether the number of pipes are equal to a variable say 10 for now. The number of pipes cannot be greater or less than 10 . Some words maybe empty string as well, such as "||||". I just need to validate the pipe count. What's inside doesn't matter.
What can be the regex for that? I am doing this using shell scripting on linux.
Also, this is just a single line. I have multiple lines in a single file(tens of thousands of records). What would be the best way to perform the validation? I have read about sed and other things, but I am not sure which one would be faster.