Re: [Hampshire] grep -50 foo /dev/sda1 runs out of memory

Top Page
Author: Hugo Mills
Date:  
To: Hampshire LUG Discussion List
Subject: Re: [Hampshire] grep -50 foo /dev/sda1 runs out of memory

Reply to this message
gpg: failed to create temporary file '/var/lib/lurker/.#lk0x58298100.hantslug.org.uk.27786': Permission denied
gpg: keyblock resource '/var/lib/lurker/pubring.gpg': Permission denied
gpg: Signature made Thu Feb 10 20:19:06 2011 GMT
gpg: using DSA key 20ACB3BE515C238D
gpg: Can't check signature: No public key
On Thu, Feb 10, 2011 at 07:20:41PM +0000, 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 </dev/sda1 | grep -100 Vishal

It's not guaranteed to work, but you might get lucky. :)

If you actually saved it, have you tried looking for that text in
extant files, rather than grepping the whole disk?

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).

Hugo.

-- 
=== Hugo Mills: hugo@... carfax.org.uk | darksatanic.net | lug.org.uk ===
  PGP key: 515C238D from wwwkeys.eu.pgp.net or http://www.carfax.org.uk
        --- Summoning his Cosmic Powers, and glowing slightly ---        
                            from his toes...