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

2006-08-07 Thread Kurt Wall
On Sun, Aug 06, 2006 at 03:47:32PM -0700, Gary Kline wrote:
 
   I've got 80 or so html/php files. Most do have 
 
   BODY BGCOLOR=#FF 
 
   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.  

I'd probably do grep -vi bgcolor filename

Kurt
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


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

2006-08-07 Thread Kurt Wall
On Mon, Aug 07, 2006 at 07:13:03AM -0400, Kurt Wall wrote:
 On Sun, Aug 06, 2006 at 03:47:32PM -0700, Gary Kline wrote:
  
  I've got 80 or so html/php files. Most do have 
  
  BODY BGCOLOR=#FF 
  
  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.  
 
 I'd probably do grep -vi bgcolor filename

[bad form to reply to my own post, etc.]

Doh! You want to *insert* the string, not (just) find the ones that 
don't have it. My ed/ex chops blow, so with sed:

sed -i '' 's/BODY/BODY BGCOLOR=#FF/' file_name

Kurt
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


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

2006-08-07 Thread Garrett Cooper

Kurt Wall wrote:

On Mon, Aug 07, 2006 at 07:13:03AM -0400, Kurt Wall wrote:
  

On Sun, Aug 06, 2006 at 03:47:32PM -0700, Gary Kline wrote:

	I've got 80 or so html/php files. Most do have 

	BODY BGCOLOR=#FF 


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.  
  

I'd probably do grep -vi bgcolor filename



[bad form to reply to my own post, etc.]

Doh! You want to *insert* the string, not (just) find the ones that 
don't have it. My ed/ex chops blow, so with sed:


sed -i '' 's/BODY/BODY BGCOLOR=#FF/' file_name

Kurt
You may just want to use CSS as well instead of hardcoding in HTML 
values like that. The background-color property is pretty much common 
and universal in all browsers, since CSS 1.0(/1.1?).

-Garrett
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


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

2006-08-07 Thread Gary Kline
On Mon, Aug 07, 2006 at 10:47:47AM -0700, Garrett Cooper wrote:
 Kurt Wall wrote:
 On Mon, Aug 07, 2006 at 07:13:03AM -0400, Kurt Wall wrote:
   
 On Sun, Aug 06, 2006 at 03:47:32PM -0700, Gary Kline wrote:
 
I've got 80 or so html/php files. Most do have 
 
BODY BGCOLOR=#FF 
 
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.  
   
 I'd probably do grep -vi bgcolor filename
 
 
 [bad form to reply to my own post, etc.]
 
 Doh! You want to *insert* the string, not (just) find the ones that 
 don't have it. My ed/ex chops blow, so with sed:
 
 sed -i '' 's/BODY/BODY BGCOLOR=#FF/' file_name
 
 Kurt
 You may just want to use CSS as well instead of hardcoding in HTML 
 values like that. The background-color property is pretty much common 
 and universal in all browsers, since CSS 1.0(/1.1?).
 -Garrett

Good thought, indeed.  Some (many) years back when I was looking at
preparing a book-length doc for the web with HTML I actually did
use the style-sheet method.  IIRC, it worked well with HTML-2.0.
But with my Jotting stuff it got a little fancier, bit-by-bit
until I had at least two jpegs/*php plus very light blue TABLE
formatting [15%, 70%, 15%], and a textured.jpg paper bg on the 
70%.  That's 3 jpegs.   I don't know if you can do something like
that with CSS.  I wound up creating *one* html/php template, and
mouse cut-and-pasting my segue, then the CENTERmeditation/CENTER
and after a few hours it was good enough... .  

I'll check into the style sheets; thanks!

gary

PS:  I also checked out Don Knuth's TeX stuff, but that's way
 overkill :-)


-- 
   Gary Kline [EMAIL PROTECTED]   www.thought.org Public service Unix

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: [freebsd-questions] awk quickie.

2006-08-06 Thread Howard Jones

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.


Have fun!

Howie
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


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

2006-08-06 Thread Gary Kline
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=#FF 

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@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/freebsd-questions
 To unsubscribe, send any mail to [EMAIL PROTECTED]

-- 
   Gary Kline [EMAIL PROTECTED]   www.thought.org Public service Unix

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


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

2006-08-06 Thread Scott Sipe


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=#FF

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=#FF  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
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


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

2006-08-06 Thread Gary Kline
On Sun, Aug 06, 2006 at 07:18:07PM -0400, Scott Sipe wrote:
 
 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=#FF
 
  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=#FF  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

Thanks, Scott.  I didn't know that -F 'char' would reset the
field separator.  I'll save this to my AWK howto.  


gary



-- 
   Gary Kline [EMAIL PROTECTED]   www.thought.org Public service Unix

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]