[ale] SED question

Pete Hardie pete.hardie at gmail.com
Wed Sep 16 16:26:25 EDT 2009


On Wed, Sep 16, 2009 at 16:08, Greg Freemyer <greg.freemyer at gmail.com> wrote:
> Thanks,
>
> We ended up modifiying a C program we had to do the job, so we are good for now.
>
> But I'm going to study what you have below.  It looks really clean and
> if this comes up again we have this as a guideline.
>
> I can also use it to double check our work and see that it does the
> same thing as the below.

Sounds like a job for awk, the next time it comes up.

awk allows field/record separator specification, and can insert data
(filename) into the data


>
> Thanks again.
> Greg
>
> On Wed, Sep 16, 2009 at 3:19 PM,  <tpike at teepee-sw.com> wrote:
>> Sed doesn't really have fields in the sense you suggest.  Here's how I
>> would do your two step process.
>>
>> Validation:
>> egrep -l -v '[^~]{1,}~[^~]{1,}~[^~]{1,}~BHT'
>>
>> That will list files that are incorrect.
>>
>> Then to add the filename:
>>
>> ls input.* | while read fn ; do
>>   sed -i -e "s/\\(BHT[^~][^~]*\\)~/\\1*$fn~/" $fn
>> done
>>
>> Substitute a for loop or find, etc for your file list as appropriate.
>>
>>> All,
>>>
>>> I have not worked much with sed.
>>>
>>> Does it have the ability to use a non-standard record and field
>>> separators?
>>>
>>> ie.  I have about 5000 files that use ~ as the record separator and *
>>> as the field separator, not <newline> and , or whatever.
>>>
>>> If it can my goal is two fold.
>>>
>>> First have verification script that verifies all 5000 files start
>>> their 4th record with BHT.  (ie. The file is
>>> "aaaa~bbbb~cccc~BHTaaaa~..."
>>>
>>> And then a separate script to append the files filename as a field to
>>> the 4th record (ie. Add *$filename to the forth record).
>>>
>>>
>>> Thanks
>>> Greg
>>> --
>>> Greg Freemyer
>>> Head of EDD Tape Extraction and Processing team
>>> Litigation Triage Solutions Specialist
>>> http://www.linkedin.com/in/gregfreemyer
>>> Preservation and Forensic processing of Exchange Repositories White Paper
>>> -
>>> <http://www.norcrossgroup.com/forms/whitepapers/tng_whitepaper_fpe.html>
>>>
>>> The Norcross Group
>>> The Intersection of Evidence & Technology
>>> http://www.norcrossgroup.com
>>> _______________________________________________
>>> Ale mailing list
>>> Ale at ale.org
>>> http://mail.ale.org/mailman/listinfo/ale
>>>
>>
>> _______________________________________________
>> Ale mailing list
>> Ale at ale.org
>> http://mail.ale.org/mailman/listinfo/ale
>>
>
>
>
> --
> Greg Freemyer
> Head of EDD Tape Extraction and Processing team
> Litigation Triage Solutions Specialist
> http://www.linkedin.com/in/gregfreemyer
> Preservation and Forensic processing of Exchange Repositories White Paper -
> <http://www.norcrossgroup.com/forms/whitepapers/tng_whitepaper_fpe.html>
>
> The Norcross Group
> The Intersection of Evidence & Technology
> http://www.norcrossgroup.com
>
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://mail.ale.org/mailman/listinfo/ale
>



-- 
Pete Hardie
--------
Better Living Through Bitmaps



More information about the Ale mailing list