Re: [Hampshire] grep -50 foo /dev/sda1 runs out of memory
Just thought I should close this off. Turned out there was a file left over from the edit session, buried in my .mozilla/whatever directory. Must have missed it when doing the 'find' command due to all the /proc and /dev entries. Didn't get anyy result with Hugo's 'tr' approach, though I may have mistyped something. But Bob Dunlop's 'strings' technique came up trumps. So, many thanks! -- best regards, Victor Churchill, Bournemouth -- Please post to: Hampshire@mailman.lug.org.uk Web Interface: https://mailman.lug.org.uk/mailman/listinfo/hampshire LUG URL: http://www.hantslug.org.uk --
Re: [Hampshire] grep -50 foo /dev/sda1 runs out of memory
On Thu, Feb 10 at 10:22, Victor Churchill wrote: ... > I believe 'grep -number' will give lines of context around > the match. Like 'grep -A 100 -B 100". grep -number is not portable -A -B is. Unless you are putting it in a script whatever works for you is fine. Anyway rather than the tr above you might want to try out strings. strings /dev/sda1 | grep -100 Vishal Strings is a filter specifically designed to find printable strings in a file so presumably designed to cope with lots of binary mush. Let's hope your tempfiles weren't stored on ramdisk. -- Bob Dunlop -- Please post to: Hampshire@mailman.lug.org.uk Web Interface: https://mailman.lug.org.uk/mailman/listinfo/hampshire LUG URL: http://www.hantslug.org.uk --
Re: [Hampshire] grep -50 foo /dev/sda1 runs out of memory
Hi Hugo, On 10 February 2011 20:19, Hugo Mills wrote: > > Possibly it's because the disk has large expanses of data with no > LF characters in it. It's most likely to be zeroes or control > characters, so I'd suggest something like: > > sudo tr -d \\000-\\011\\013-\\037 > It's not guaranteed to work, but you might get lucky. :) Giving it a go... > > If you actually saved it, have you tried looking for that text in > extant files, rather than grepping the whole disk? Well I *thought* I had saved it ;-) I did try find / -mmin -60 but was deluged with unexpected stuff from the /proc and /dev file systems, and couldn't figure out how to use -prune so gave up on that. But I suspect the file might have been deleted by the Firefox plugin after I exited the editor. Hence trying a punt on grepping the disc. > > Also, note that you're only going to get one line of the output > with little or no indication of where in the disk it is, so you > _still_ won't have the data -- just one line of it and no idea of > where the rest is, so the above incantation probably isn't what you > need. (I'm too tired right now to think of what it is that you _do_ > need, though; sorry. Maybe someone else can help with that). > I believe 'grep -number' will give lines of context around the match. Like 'grep -A 100 -B 100". -- best regards, Victor Churchill, Bournemouth -- Please post to: Hampshire@mailman.lug.org.uk Web Interface: https://mailman.lug.org.uk/mailman/listinfo/hampshire LUG URL: http://www.hantslug.org.uk --
Re: [Hampshire] grep -50 foo /dev/sda1 runs out of memory
On Thu, Feb 10, 2011 at 20:19, Hugo Mills wrote: > Also, note that you're only going to get one line of the output > with little or no indication of where in the disk it is, so you > _still_ won't have the data -- just one line of it and no idea of > where the rest is, so the above incantation probably isn't what you > need. (I'm too tired right now to think of what it is that you _do_ > need, though; sorry. Maybe someone else can help with that). a VERY long-whinded and brute-force way would be to pass every file on the system through grep, something like: find / -type f -exec grep Vishal '{}' \; However, this again will just give one line of output for each match instead of the whole file, and won't tell you which file contained the match. I too can't think right now. -- Please post to: Hampshire@mailman.lug.org.uk Web Interface: https://mailman.lug.org.uk/mailman/listinfo/hampshire LUG URL: http://www.hantslug.org.uk --
Re: [Hampshire] grep -50 foo /dev/sda1 runs out of memory
On Thu, Feb 10, 2011 at 07:20:41PM +, Victor Churchill wrote: > So I recalled this grep trick.Unfortunately it chugs for a while then > exits with an error: > > victor@pan2:~$ sudo grep -100 Vishal /dev/sda1 > grep: /dev/sda1: Cannot allocate memory > > I /thought/ grep would work through a file of any size... is ther > anything I can do about this? Possibly it's because the disk has large expanses of data with no LF characters in it. It's most likely to be zeroes or control characters, so I'd suggest something like: sudo tr -d \\000-\\011\\013-\\037 http://www.carfax.org.uk --- Summoning his Cosmic Powers, and glowing slightly --- from his toes... signature.asc Description: Digital signature -- Please post to: Hampshire@mailman.lug.org.uk Web Interface: https://mailman.lug.org.uk/mailman/listinfo/hampshire LUG URL: http://www.hantslug.org.uk --
[Hampshire] grep -50 foo /dev/sda1 runs out of memory
Hi, I have a firm recollection of reading war stories in the past about how the above incantation will find textual information on the disk that you have mislaid (the information, that is, not the disk). So I had exited an editor session attached to my GMail through the "It's All Text!" Firefox extension, which lets you fill in textareas in an external editor. Except in this case it didn't - I typed stuff in for about 20 minutes, saved, exited and the work was /not/ in my mail window. Bother, said Pooh. So I recalled this grep trick.Unfortunately it chugs for a while then exits with an error: victor@pan2:~$ sudo grep -100 Vishal /dev/sda1 grep: /dev/sda1: Cannot allocate memory I /thought/ grep would work through a file of any size... is ther anything I can do about this? thanks, victor -- best regards, Victor Churchill, Bournemouth -- Please post to: Hampshire@mailman.lug.org.uk Web Interface: https://mailman.lug.org.uk/mailman/listinfo/hampshire LUG URL: http://www.hantslug.org.uk --