Howto insert string. (Was: Re: [freebsd-questions] awk quickie.)

Gary Kline kline at tao.thought.org
Sun Aug 6 22:47:53 UTC 2006


On Sun, Aug 06, 2006 at 11:23:14PM +0100, Howard Jones wrote:
> Gary Kline wrote:
> >	Guys,
> >
> >	Can aanybody spot what I'm doing wrong in this tiny awk scripy::
> >  
> Using awk is what you are doing wrong ;-) Assuming that this is all you 
> are doing with the list, anyway...
> 
> From the grep manpage:
> "       -l, --files-with-matches
>              Suppress  normal  output;  instead  print the name of each 
> input
>              file from which output would normally have  been  
> printed.   The
>              scanning will stop on the first match."
> 
> The awk answer is that the printf shouldn't be in the BEGIN section, I 
> think. It's been a while for me and awk though. Something more like:
> 
> #!/usr/bin/awk
> BEGIN { FS = ":" }
>      {  printf("%s\n", $1) }
> 
> would do it. Also see cut(1) which can select fields based on delmiters. 
> I don't know if the traditional perception of 'heaviness' associated 
> with loading a 'real language' interpreter really hold true nowadays though.
> 


	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



> Have fun!
> 
> Howie
> _______________________________________________
> freebsd-questions at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "freebsd-questions-unsubscribe at freebsd.org"

-- 
   Gary Kline     kline at thought.org   www.thought.org     Public service Unix



More information about the freebsd-questions mailing list