LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Closed Thread
  Search this Thread
Old 09-01-2016, 04:52 PM   #1
awesomereqs
LQ Newbie
 
Registered: Sep 2016
Posts: 3

Rep: Reputation: Disabled
Using dd for retrieval of data


Hello,

I did post about how to use dd searching for strings, but it may have got lost in the ether.

Anyway, I cannot find any usage of using dd in an intelligent way to find strings of data, then save data before and after the string to a text file on a different drive.

There are a few variables that I do know, that there is a string with the exact string 'apply-online-for-student-finance' that I want to find. I know the file is 206kb, and also that the string is the last thing I wrote to the file and then saved it, so there will be 206kb data preceding that string.

So I'd be using if=/dev/hda1 of=/dev/hda2/newfile.txt
and for every instance of 'mystring'
to do a new file, which would be newfile1.txt, newfile2.txt, newfilen.txt, etc.

I was thinking, could I get 2 variables a and b, then allocate 206k to each sequentially, overwriting each one with the next lot of 206k of data to read in, and if 'mystring' is not in a then search for it in b, if it is not located in b then get the next lot of data and allocate it to a, then if it is in a then add b then a to the text file, which would be how I can be sure of getting the 206k of data previous to my string, and continue until the end of the disk or partition.

So to put that in a loop, is also a challenge, and I am new to this, but the logic would be something like:

while data exists on $driveA #the partition we are searching
if !a then allocate next 206k to b, then if !b then allocate next 206k to a;

As a script, I could pass a few variables to it, like:
ddscript 'mystring' if_area of_area file_size

Would the logic work? Any answers would have gratuitous praise.

Thanks
 
Old 09-01-2016, 06:16 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Moved to Linux Genral forum and closed as dupe of post https://www.linuxquestions.org/quest...ml#post5599247
 
  


Closed Thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Data retrieval cholas Linux - General 2 07-02-2007 03:40 AM
Website member login and data retrieval lord-fu Programming 3 03-13-2006 02:27 PM
code retrieval linuxhippy Slackware 3 12-22-2005 01:09 PM
what are the best data retrieval tools for linux newusermike Linux - Newbie 1 07-31-2005 10:31 PM
Data retrieval - HELP! 3l10 Linux - Hardware 1 01-05-2004 03:25 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:53 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration