-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
search backwards can't find strings on large files with lots of carriage-returns #40
Comments
If the file contains no newline characters, it's seen by less as one gigantic line. So searching won't work because it's viewing everything as being on the same line. When you search for text, it thinks you're already on that line so it doesn't need to move. Less wasn't really intended for viewing non-text files, meaning files which isn't predominantly printable characters in reasonable length lines separated by newlines. |
The issue I detected wasn't less "not moving", was it explicitly saying that the search string was not found. This is a different situation, right? |
If there is one instance of a string in a file and you are positioned on that line, and you then search for the string, less will not move and will display "Pattern not found", meaning there are no more instances of the pattern to be found in that direction. So I believe it is the same situation as I described. |
When searching backwards (ie, first going all the way to EOF by typing
G
and then using?string
),less
reports that the string can't be found when it was obviously there (e.g, copy-pasted using the mouse from the initial screenful, before typingG
).I've been using
less
for over 20 years and have not seen this until now; the only possible causes I can attribute to this issue is that the file is relatively large (~2.3GB) and has a lot (eg, millions) of lines terminating on a single ^M (carriage-return with no line-feed).in fact, after replacing all carriage-returns with newlines on the file, eg with
bbe -e 's/\r/\n/g' <large_file_with_carriage-returns >large_input_file_with_newlines
and then runningless large_input_file_with_newlines
instead, backwards search now works, successfully locating the same strings it failed to find in file_with_carriage-returns.More details:
The text was updated successfully, but these errors were encountered: