Search for a pattern of three digits, followed by an optional hyphen, followed by three digits, followed by an optional hyphen, followed by four digits in all .txt files in the current directory and its subdirectories, and print only the filenames that match the pattern.
grep -q -E '^[0-9]{3}[-]?[0-9]{3}[-]?[0-9]{4}$' $(find ./ -name '*.txt' -exec ls -1S {} +)