appending the text of a file to a bunch of files in a folder

appending the text of a file to a bunch of files in a folder

Post by fnor » Sun, 03 Jun 2001 05:09:25



I need to append the text of a file called newcss to all of the files called
main.css in a lot of subfolders.

I was thinking that I could just do this:

find /folder -name main.css | more /newcss >> $1

but, it appears that when the find command returns, $1 isn't going to cut
it...

can anyone help me out on this?

thanks,
fnord

 
 
 

appending the text of a file to a bunch of files in a folder

Post by Chris F.A. Johnso » Sun, 03 Jun 2001 06:48:44



> I need to append the text of a file called newcss to all of the files called
> main.css in a lot of subfolders.

> I was thinking that I could just do this:

> find /folder -name main.css | more /newcss >> $1

> but, it appears that when the find command returns, $1 isn't going to cut
> it...

for file in `find  /folder -name main.css`
do
        cat /newcss >> $file
done

..or..

find  /folder -name main.css | while read file
        do
                cat /newcss >> $file
        done

--

        =================================================================



 
 
 

appending the text of a file to a bunch of files in a folder

Post by Michael Heimin » Sun, 03 Jun 2001 06:53:35



> I need to append the text of a file called newcss to all of the files called
> main.css in a lot of subfolders.

> I was thinking that I could just do this:

> find /folder -name main.css | more /newcss >> $1

> but, it appears that when the find command returns, $1 isn't going to cut
> it...

> can anyone help me out on this?

> thanks,
> fnord

for i in `find /folder -name main.css`; do cat newcss >> $i; done

should do the trick.

Michael Heiming

 
 
 

appending the text of a file to a bunch of files in a folder

Post by Marty McGow » Thu, 07 Jun 2001 13:16:30




> > I need to append the text of a file called newcss to all of the files called
> > main.css in a lot of subfolders.

> > I was thinking that I could just do this:

> > find /folder -name main.css | more /newcss >> $1

> > but, it appears that when the find command returns, $1 isn't going to cut
> > it...

> > can anyone help me out on this?

> > thanks,
> > fnord

> for i in `find /folder -name main.css`; do cat newcss >> $i; done

> should do the trick.

> Michael Heiming

not to steal anything, but

  another opportunity for "foreach"

 function list_of  { find /folder -name $1; }
 function main_list { list_of main.css'; }
 function append_to { cat newcss >> $1; }
 foreach append_to $(main_list)

 
 
 

1. unzip a bunch of files to screen and append text to EACH line????

Hi,
Following is my problem:
I have a large number of zip files in a directory with A LOT of
(text)data in them (each zip only has one text file).  I would like to
unzip them, look at each file and append the name of the zip file to
the beginning of each line in the content.  In other words:

unzip <large number of *.zip>
--this produces a large number of *.dat or *.DAT files
append the text 'XYZ.zip' to each line in XYZ.dat (repeat this for all
*.zip and their related *.dat file).
Essentially I am eventually going to concat all the *.dat files, but
would like to know which *.zip each line belongs to.

I've tried various combinations of 'for name in *.zip ....', 'find .
*.zip -exec ...', ' ...|xargs ...', etc., etc. but nothing seems to
work.  I would REALLY like to avoid writing a perl script.  Any ideas?
 Thanks.

Shahbaz

2. openbsd as ip masq?

3. appending binary file in a text file

4. problem with users-> wu-ftp 2.4 on solaris

5. Search and replace text in a bunch of text files..

6. floppy access: ioctl(FDGETPRM): No such device

7. Search and replace text in a bunch of text files

8. How to move files by modification date?

9. copy a bunch of text 100 times with in a file

10. MS-window text file viewer to read a text file in SCO server.

11. Dos Text Files to Linux Text Files

12. tools to seperate one large text file into two small text files?

13. Extracting lines from a text file that match a certain criteria to another text file