Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 6 Aug 2006 19:18:07 -0400
From:      Scott Sipe <cscotts@mindspring.com>
To:        Gary Kline <kline@tao.thought.org>
Cc:        freebsd-questions <freebsd-questions@freebsd.org>
Subject:   Re: Howto insert string. (Was: Re: [freebsd-questions] awk quickie.)
Message-ID:  <A90BBE5F-0E41-4922-BCD8-6E1C7114FFCA@mindspring.com>
In-Reply-To: <20060806224732.GA1255@thought.org>
References:  <20060806221015.GA1039@thought.org> <44D66BD2.8050305@thingy.com> <20060806224732.GA1255@thought.org>

next in thread | previous in thread | raw e-mail | index | archive | help

On Aug 6, 2006, at 6:47 PM, Gary Kline wrote:
>
> 	Thanks much!  I *did* learn that with just FS, no need "END".
> 	Maybe you can help me figure out what I'm trying to do because
> 	I'm wedged!!
>
> 	I've got 80 or so html/php files. Most do have
>
> 	<BODY BGCOLOR=#FFFFFF">
>
> 	but a whole slew do not/are missing the BG color code.
> 	So is there some scripto-magic way of finding out which fles are
> 	missing the above string?  I know how, using an ed/ex script to
> 	insert this string.
>
> 	My hacker brain seems to be on strike!
>
> 	gary

Not 100% sure this is what you're wanting, but you can just do  
something like:

grep "myregex" * | awk -F ':' '{print $1}'

This will print out the first column (ie, whatever comes before the  
first colon).

if the options are either "<BODY>" or "<BODY BGCOLOLR="#FFFFFF">"  I  
guess you  could do something like:

grep "<BODY" * | grep -v BGCOLOR | awk -F ':' '{print $1}'

to get the files that have a body line sans BGCOLOR (you might need  
to account for case in the tags also)

Scott



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?A90BBE5F-0E41-4922-BCD8-6E1C7114FFCA>