less
less copied to clipboard
Can less search for hexadecimal values in a 73GB file?
Hi,
consider the following file
"topics":["0xe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c","0x0000000000000000000000000000000000007f150bd6f54c40a34d7c3d5e9f56"],"data":"0x00000000000000000000000000000000000000000000000007dec64b14149040","blockNumber":"0xb079ad","transactionHash":"0x87e4e72189966e7f1e5578810c46a9c8180f9d240c4bb511c58d568bc352d300","transactionIndex":"0x1d0","blockHash":"0x413cf9b1f779d0b6bd52113aa6bd3462b5010cd8c50a1229ac28103d44c4d640","logIndex":"0x3","removed":false},{"address":"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2","topics"
I can open it with less at a specific cursor, e.g. less -p 0x413cf9b1f779d0b6bd52113aa6bd3462b5010cd8c50a1229ac28103d44c4d640 file
and then the 0x413cf9b1f779d0b6bd52113aa6bd3462b5010cd8c50a1229ac28103d44c4d640
gets highlighted in white by the shell.
More importantly, I can visually confirm that less is indeed finding this string.
But then, I also have a 73GB file and I'm doing the same thing. However, while less searches for some time, it then stops, there is no highlighted text anywhere and generally I'm not able to visually confirm the string's existence in the current screen buffer. I've managed to exclude that it is my fault by copy pasting the whole text buffer into another editor to search for the existence of the supposed string. It is not there. What is going on?
What version of less are you using? Does the file contain very long lines (say, longer than 2000 characters) or is just a lot of short lines? Also, when you say "it then stops", exactly what do you see? That is, what part of the file is displayed at that point? Is it still at the beginning of the file or somewhere else? Do you see a "Pattern not found" message at the bottom of the screen or just a colon? If you use the -J option, do you see an asterisk in the first column of any line on the screen?
What version of less are you using?
less --version
less 551 (GNU regular expressions)
Copyright (C) 1984-2019 Mark Nudelman
less comes with NO WARRANTY, to the extent permitted by law.
For information about the terms of redistribution,
see the file named README in the less distribution.
Home page: http://www.greenwoodsoftware.com/less
Does the file contain very long lines (say, longer than 2000 characters) or is just a lot of short lines?
Long lines. For sure some are beyond 2k characters.
Also, when you say "it then stops", exactly what do you see?
It stops like as if it found something. But in the visible buffer no highlighted text string can be found and I'm also not able to find the text that I was searching for by visibly searching the screen with my eyes.
That is, what part of the file is displayed at that point?
I'm not sure. The files are 73 GB or 500GB and it's hard for me to tell to which point less teleports me. Any idea how I could check within less? Can I maybe get the offset in the file of the current cursor position?
Do you see a "Pattern not found" message at the bottom of the screen or just a colon?
I think just a colon.
If you use the -J option, do you see an asterisk in the first column of any line on the screen?
I'll have to get back to you on that one
less-551 is a pretty old version. I would guess that what's happening is less is finding the target text, and scrolling to the desired line, but the text is towards the end of a very long line so that it doesn't appear on screen. If you were to manually scroll right you would find it. In less-581 a change was made so that in this situation less will automatically scroll right to bring the target text into view. I would suggest trying the currently released version (less-590) and see if the problem is fixed in that version.
BTW you can tell where you are in the file by pressing the '=' key.
Closing as no response.