Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

appending common content to every *.prj file in subdirectories

Status
Not open for further replies.

RVSachin

Technical User
Nov 12, 2001
77
IN
Hi,

I have a file abc.prj in each of many subdirectories.
I need to append the contents of myfil.txt to every abc.prj file in the subdirectories.

Can somebody please help me out on this?

The structure is as follows:

Main ---|
|subdir1 --> abc.prj
|subdir2 --> abc.prj
|subdir3 --> abc.prj
|subdir4 --> abc.prj


|subdirn --> abc.prj


abc.prj should be appended with the contents of myfil.txt.


Thanks,

RV
 
Something like this ?
find Main -name abc.prj -exec cat /path/to/myfil.txt >> {} \;

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
something similar to this:
You may need to change the 'fileA' using the actuall pathname to a file to add. And also change the '.' in the 'find' to point to the 'start' of the directory to search.

Code:
#!/bin/ksh

fileA='abc.prj'

find . -type f -name 'abc.prj' | while read file 
do
  ex - ${file} <<-EOF
        $
        r ${fileA}
        wq!
        EOF
done;

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top