I'm trying to find a certain unknown 11 character sequence in a huge packet capture file. The one thing I do know is that the string I'm looking has format x.x-xxxxxxx. I've been looking for a while and cannot find the right grep statement to accomplish this, can anyone help?
grep a certain format, is this possible?
grep;regular expression
The format for grep is what we call a POSIX regular expression (look it up) and it support some simple matching primitives. If you know you want just alpha-numeric characters, you can use a character class like this: [a-zA-Z0-9]. grep even has a shortcut for this specific class (because it is so useful) like this: [[:alnum:]]. man grep has a lot more information about that.You can also use repetition counting to specify how many of these characters you want to match. In your case you want to match: 1 alpha-numeric character, then a period, then one more character, then a dash followed by 7 characters. In POSIX regular expression this looks like so:[[:alnum:]]\.[[:alnum:]]-[[:alnum:]]{7}Notes:I had to escape the period with a backslash, otherwise it will be resolved as the catch all characters regular expression.In order for the repetition clause (the curly braces) to work you'd need to enable extended regular expression mode using -e or by running egrep instead of the standard grep.So the full command may look like this:egrep '[[:alnum:]]\.[[:alnum:]]-[[:alnum:]]{7}' /some/fileThe output will be the lines where that expression matched, possibly highlighted in color (depending on your terminal). If your packet file is not line delimited (maybe it is binary) expect a lot of mess on the screen.