In unix, what's a grep/regular-expression command to search a directory for files containing a string like "b1234567", where the first character is a lowercase "b", followed by seven numerals?
You can use the grep
command with the -r
(or --recursive
) option to search a directory recursively. To find a pattern like "b1234567", where the first character is a lowercase "b", followed by seven numerals, you can use the regular expression b[0-9]{7}
. Here's how to put it all together: