How to check if a string inside file is longer than 50 characters.
Hi,
I am wondering if it is possible to use find and grep to search inside files to check if there is a string longer than 50 characters inside files. Thanks, |
To search in one file:
Code:
grep -e '[^\ ]\{50,\}' /path/to/file Code:
grep -Re '[^\ ]\{50,\}' /path/to/directory |
It would help if you gave a few more details. What constitutes a "string"? Do you mean whitespace-delimited characters? Whole lines? What? Perhaps you could give us a bit of sample text?
The suggestion given above searches for strings of 50 or more consecutive non-space characters. You can avoid the backslashes, however, by using the "-E" extended regex option, and you don't need to use "-e" when there's only a single expression. Code:
grep -E '[^[:space:]]{50,}' /path/to/file "[^\ ]" is wrong in either version, BTW, as it means "not a backslash or a space". All simple characters are considered literal when inside a regex bracket expression except for "^","-", and "]", and even those are made unspecial by placing them in certain positions inside the brackets (i.e. "^" is only special if it's the first character in the list). |
Here is the examples of the strings:
xGaaSZgwC2bw5Fl2RaWS1yw 2ecacebe01e77fe2dd40 Thank you! |
Thank you all. I got my answer with your help.
|
All times are GMT -5. The time now is 01:23 AM. |