[ale] SED question

tpike at teepee-sw.com tpike at teepee-sw.com
Wed Sep 16 15:19:54 EDT 2009


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
>



More information about the Ale mailing list