Re: [SLUG] bash script - add new line breaks to a text file

From: Mike Branda (mike@wackyworld.tv)
Date: Tue Nov 08 2005 - 15:11:32 EST


On Tue, 2005-11-08 at 13:27 -0500, Ian C. Blenke wrote:

> >fff8e5a2e87f6b1a35b594fb309e2c56 /filedir6/file7
> >fff8e5a2e87f6b1a35b594fb309e2c56 /filedir6/my_files/file7
> >
> >I was wondering if anybody has a bash suggestion for reading the 32 char
> >MD5 or the first 32 chars on the line and comparing it to the next line
> >and if they aren't the same, insert a new blank line in between them.
> >
> >
> Something like this:
>
> $ cat dupliFinder.txt | ( last=""; while read line; do hash=`echo
> $line | awk '{print $1}'`; if [ "$hash" != "$last" ]; then echo ""; fi;
> echo $line ; last=$hash; done)
>
> That does it.
>
> - Ian C. Blenke <ian@blenke.com> http://ian.blenke.com/

Thanks Ian. That did it. Now to study up on the logic!!

Mike Branda Jr.

-----------------------------------------------------------------------
This list is provided as an unmoderated internet service by Networked
Knowledge Systems (NKS). Views and opinions expressed in messages
posted are those of the author and do not necessarily reflect the
official policy or position of NKS or any of its employees.



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 19:53:49 EDT