sed insert content of file.txt to multi files


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers sed insert content of file.txt to multi files
# 1  
Old 05-07-2011
sed insert content of file.txt to multi files

Ive this sed & find command

Code:
find /home/www/ -name footer.php -exec sed -i 's/<\/body>/file.txt\n<\/body>/'

what I need to place content of file.txt before </body> in all footer.php files


file.txt content is google analytic script which is like 7 lines

any help to adjust my command to read content and place it before </body>
!

Last edited by Franklin52; 05-07-2011 at 09:23 AM.. Reason: Please use code tags
# 2  
Old 05-07-2011
Try:
Code:
find . -name footer.php -exec perl -i -pe 'print `cat file.txt` if /<\/body>/' {} \;

# 3  
Old 05-08-2011
works , Smilie thanks alot buddy!
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Copy the content from txt file and create a html file

I have a txt file with a list of error messages in a xml tag format, and each error message is separated with a identifier(endresult).Need to split that and copy and create a new html file.Error message has some special character. how to escape the special character and insert my data into the... (7 Replies)
Discussion started by: DevAakash
7 Replies

2. Shell Programming and Scripting

How to substract selective values in multi row, multi column file (using awk or sed?)

Hi, I have a problem where I need to make this input: nameRow1a,text1a,text2a,floatValue1a,FloatValue2a,...,floatValue140a nameRow1b,text1b,text2b,floatValue1b,FloatValue2b,...,floatValue140b look like this output: nameRow1a,text1b,text2a,(floatValue1a - floatValue1b),(floatValue2a -... (4 Replies)
Discussion started by: nricardo
4 Replies

3. Shell Programming and Scripting

SED - insert space at the beginning of line and multi replace command

hi I am trying to use SED to replace the line matching a pattern using the command sed 'pattern c\ new line ' <file1 >file 2 I got two questions 1. how do I insert a blank space at the beginning of new line? 2. how do I use this command to execute multiple command using the -e... (5 Replies)
Discussion started by: piynik
5 Replies

4. Shell Programming and Scripting

Reset different and multiple .txt file content to 0

I need help. I have to create a cron job that will reset the value of different and multiple .txt file to 0. Example: Actual 172_21.txt = 25 192_101.txt = 10 192_168.txt = 5 10_10.txt = 3 After the cron job 172_21.txt = 0 192_101.txt = 0 192_168.txt = 0 10_10.txt = 0 The cron... (2 Replies)
Discussion started by: jasperux
2 Replies

5. UNIX for Dummies Questions & Answers

Help with Aligning the content of a txt file

Hello friends Please help me to display the content of a file in specific aligned manner. for ex. the content of the file may be >$TEST WELCOME HI HELLO UNIX SHELL SCRIPTING >$ I want to display the content like . TEST WELCOME HI HELLO ... (18 Replies)
Discussion started by: rajmohan146
18 Replies

6. Programming

[SQL] Insert content file to mysql

dear all, i want to insert string in file to mysql i just want how to do that cause i am poor in sql languages ... so this file like this DATA.txt doni|student|westjava|123412|lombok| iwan|student|westjava|1234412|utankayu| rio|student|westjava|12342|cempedak| so i want insert DATA.txt to... (2 Replies)
Discussion started by: zvtral
2 Replies

7. Shell Programming and Scripting

Insert file.txt recursively

Anyone knows how I can change this script so that it works recursively as well (meaning: *.c files in sub directories will get changed as well)? for file in *.c do cat file.txt "$file" > tempfile cat tempfile > "$file" done rm tempfile (5 Replies)
Discussion started by: psve
5 Replies

8. Shell Programming and Scripting

how to create file.txt and add current date in file content

Hey guy, how to make bash script to create foo.txt file and add current date into file content and that file always append. example: today the script run and add today date into content foo.txt and tomorrow the script will run and add tomorrow date in content foo.txt without remove today... (3 Replies)
Discussion started by: chenboly
3 Replies

9. Shell Programming and Scripting

Extract content from several txt-files

Hi! Im trying to write a script in ksh that creates a single txt-file from specific content in several other txt-files. From these files I want to extract all text after 'WORD' and before '=', regardless of number of lines and other content. I have tried cat and guess I need... (7 Replies)
Discussion started by: larsu
7 Replies

10. Shell Programming and Scripting

Insert file content via sed after two searchings

Hi folks, The file webcache.xml contains a lot sections which begins and ends with the string </CACHEABILITYRULE>. The section In need to deel with is: </CACHEABILITYRULE> <CACHEABILITYRULE NAME="cache swf" CACHE="YES" COMMENT="This rule caches all .swf files. This... (2 Replies)
Discussion started by: nir_s
2 Replies
Login or Register to Ask a Question