Yahoo : Winternet : TC Guide  : Files of Local Interest Enter Sysinfo.com :

Subject: Re: How do I cat one file on top of the BEGINNING of another file?
Subject: Re: Was wondering...
Subject: Re: Was wondering...
Date: Tue, 13 Feb 1996 14:57:17 -0600
Newsgroups: comp.unix.misc
From: jjk@lbvrtda.logica.com (JJ Keijser)
Newsgroups: comp.unix.misc
Subject: Re: How do I cat one file on top of the BEGINNING of another file?
Date: Mon, 05 Feb 96 08:48:52 GMT
Lines: 26

In article <9602011351.AA08682@pag1.agt.gmeds.com>,
   "David S. Pesetsky 230-6088 AGT/8880" <iedsp@agt.gmeds.com> wrote:
>I'm trying to figure out (in bsh) how to overwrite file A (starting at
>it's beginning) with file B. In other words, if file A is bigger, file B
>will fit inside file A, and will start at file A's begining. The final file
>A will not change size and will consist of all of file B, and the REST
>of file A. Any way to do it?

ummm, try something like
(cat B; tail -`wc -l fileB | awk '{print $1 + 1 }'` fileA) >> newA

Experiment before you overwrite !!! This will append the entire file A to file 
B if file B is bigger than A.

HTH,

JJ


----------------------------------------------------------
  Jan Just (JJ) Keijser
  SMTP: jjk@lbvrtda.logica.com
  X400: C=GB A=ATTMAIL P=Logica O=LBV OU1=LBVRTDA S=JJK
  I prefer clear blue skies over a bunch of clouds any day
  My views are my own...
----------------------------------------------------------

--

Date: Wed, 21 Feb 1996 21:52:11 -0600
Newsgroups: winternet.help.unix
From: drow@winternet.com (CARRIER LOST)
Newsgroups: winternet.help.unix
Subject: Re: Was wondering...
Date: 22 Feb 1996 02:55:37 GMT
Lines: 45

Aliens and the CIA made Aaron C. Paulley (paulley@winternet.com) write:
> Is there a UNIX way to easily append a file to a set of files (i.e., a
> disclaimer to the bottom of a bunch of .html files)?

it depends on exactly what you need to do.  if you can literally append to
a file...

    bourne shells (sh, ksh, bash)

	for file in *.html; do
	    cat disclaimer.txt >> $file
	done

    c shells (csh, tcsh)

	foreach file (*.html)
	    cat disclaimer.txt >> $file
	end

most html files have a </body> and </html> at the end though, right?  :)
i usually use sh, sed, or awk scripts to search for the end tags and insert
a block of text.  it helps a lot if all your html files are laid out
consistently.  

	#!/bin/sh
	#  written off the top of my head, usual disclaimers apply.

	for file in *.html; do
	    ( while read line; do
		if [ "$line" = "</body>" ]; then
		    cat disclaimer.txt >> $file.new
		fi
		echo "$line" >> $file.new
	    done ) < $file
	    mv $file.new $file
	done

bonus clue:  make a backup tar of everything before making scripted
changes.  not much sucks worse than trashing all your files by mistake.  :)

--
	"Today is Election Day, and we urge all citizens to vote NO
	with the weapon of their choice."
						- KViSR Radio
						  "The Voice of Anarchy"

--

Date: Thu, 22 Feb 1996 15:15:47 -0600
Newsgroups: winternet.help.unix
From: dalem@arh.com (Dale Mensch)
Newsgroups: winternet.help.unix
Subject: Re: Was wondering...
Date: 22 Feb 1996 07:43:46 -0600
Lines: 37
	<4gglv9$l8@blackice.winternet.com>
In-reply-to: drow@winternet.com's message of 22 Feb 1996 02:55:37 GMT

Aliens and the CIA made Aaron C. Paulley (paulley@winternet.com) write:
> Is there a UNIX way to easily append a file to a set of files (i.e., a
> disclaimer to the bottom of a bunch of .html files)?

 drow> bonus clue:  make a backup tar of everything before making scripted
 drow> changes.  not much sucks worse than trashing all your files by
 drow> mistake.  :)

It can suck even less: whenever I change files that I rely on, I use
sort of version control to let me incrementally back out any changes
I've made.  I'd stick in some RCS CheckOut and CheckIn commands before
and after the editting:

#!/bin/sh
#  written off the top of my head, usual disclaimers apply.

for file in file? ; do
    co -l $file
    ( while read line; do
	if [ "$line" = "</body>" ]; then
	    cat disclaimer.txt >> $file.new
	fi
	echo "$line" >> $file.new
    done ) < $file
    mv $file.new $file
    ci $file <<EEOOFF
Inserted weasly CYA verbage
to dodge CDA
EEOOFF
done
-- 
---
Dale Mensch -- contracting with Euler Solutions at Automated Wagering
dale::opinion && (euler::opinion || AWI::opinion) == NULL
  GCS d- s+:+ a+ C++ U++$ P+++$ L+++ E++ W+ N++ !K w+ !O !M !V PS+ PE-
  Y PGP- t+ 5 X+ !R tv-- b++ DI++++ D++ G e++ h---- r+++ y++++
Mpls, MN -- dalem@arh.com (w), dmensch@maroon.tc.umn.edu (h)

--

Yahoo : Winternet : TC Guide  : Files of Local Interest Enter Sysinfo.com :



Hosted by: Enter:  sysinfo.com


©copyright 1995-2002 sysinfo.com