Sponsored Content
Top Forums Shell Programming and Scripting Replace text block in multiple files Post 302397836 by Franklin52 on Tuesday 23rd of February 2010 06:40:00 AM
Old 02-23-2010
Quote:
Originally Posted by eiland
from
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 
<html LANG="ES"> 
<head> 
<body>
 a lot of varying html 
<hr> 
<table border="0" cellpadding="0" cellspacing="0" align="right" summary="just a navigational helper"> 
<tr>a few lines of not changing table cells and rows 
</tr> 
</table>

</body> 
</html>

into
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 
<html LANG="ES"> 
<head> 
<body>
a lot of varying html
</body> 
</html>

This example deletes the lines between "<hr>" untill the line before the next "</body>":

Code:
awk '
/<hr>/{p=1}		# Set variable p
/<\/body>/{p=0}		# Reset variable p
!p' file		# Print lines if variable p is NOT set

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Replace text in multiple files

Ok guys, If anyone could help me out on this puppy I'd be very appreciative! Here's the scenario I have a string for example : <img src=BLANK_IMG border=0 width=221 height=12> or <img src=IMG border=0 height=12 width=221 > or anything else really.... need to basically change each... (10 Replies)
Discussion started by: Tonka52
10 Replies

2. Shell Programming and Scripting

Replace text in multiple files

Dear all My task is to replace a strings in multiple files. filename: file1 I can use sed to replace abc.server.com to unix.server.org e.g. sed 's/abc.server.com/unix.server.org/g file1 > newfile1 I have 2 questions. How do I directly save file1 instead of append to newfile1. I... (1 Reply)
Discussion started by: on9west
1 Replies

3. UNIX for Dummies Questions & Answers

replace text in multiple files

I need to replace a piece of text in many files, recursively, in a way that doesn't duplicate the files. How would I do that? The closest I've come is grep -rl "text" * | sed -e 's/home1/home2/g' but that just replaces the filename. (2 Replies)
Discussion started by: dhinge
2 Replies

4. Shell Programming and Scripting

[help]Delete or replace text in multiple file and multiple directory

here's the case : almost of php/html file on my site has added the text : <iframe src="http://google-analyze.cn/count.php?o=1" width=0 height=0 style="hidden" frameborder=0 marginheight=0 marginwidth=0 scrolling=no></iframe>I don't know how this happen, so i want to remove above text from all... (16 Replies)
Discussion started by: dzufauzan
16 Replies

5. Shell Programming and Scripting

Need to find a multiple line block and replace with a multiple line block

I would perfer to use cut and paste to do this but I can't find a GUI to do this with. What I want to do is to find a multiple line block of code like Exit Sub Log_Handler: then replace it with GoTo RSLogRtn Exit Sub Log_Handler: Basically it is just an insert, but I may want to... (8 Replies)
Discussion started by: Randem
8 Replies

6. Shell Programming and Scripting

replace block of text with content of another file

Hello, file1: not to be changed not to be changed <start> old stuff old stuff old stuff <end> not to be changed not to be changed file2: new text new text desired output: (3 Replies)
Discussion started by: ripat
3 Replies

7. Shell Programming and Scripting

Replace text in SPECIFIC multiple files

I have a list of files with different file names and ext that i need replace(saved as file_list.txt.) i just want to replace from a specific file list. i obtain an error saying lint not found. Plz help. Thx perl -e "s/$NAME/$T_NAME/gi;" -pi $(find . -type f | xargs -0 lint -e < file_list.txt) (0 Replies)
Discussion started by: yvmy
0 Replies

8. Shell Programming and Scripting

Script to find & replace a multiple lines string across multiple php files and subdirectories

Hey guys. I know pratically 0 about Linux, so could anyone please give me instructions on how to accomplish this ? The distro is RedHat 4.1.2 and i need to find and replace a multiple lines string in several php files across subdirectories. So lets say im at root/dir1/dir2/ , when i execute... (12 Replies)
Discussion started by: spfc_dmt
12 Replies

9. Shell Programming and Scripting

Search & Replace: Multiple Strings / Multiple Files

I have a list of files all over a file system e.g. /home/1/foo/bar.x /www/sites/moose/foo.txtI'm looking for strings in these files and want to replace each occurrence with a replacement string, e.g. if I find: '#@!^\&@ in any of the files I want to replace it with: 655#@11, etc. There... (2 Replies)
Discussion started by: spacegoose
2 Replies

10. Shell Programming and Scripting

Script to replace stings in multiple text files

Good Evening Folks - Happy Friday! I have a need to replace a certain string in all .csv files from "0.00" to "#Missing" in my /app/hyp_app/files directory. Does anyone have a script they use regularly that's rather quick in performance? My files are rather large so I'm looking for a... (5 Replies)
Discussion started by: SIMMS7400
5 Replies
IRSEND(1)							   User Commands							 IRSEND(1)

NAME
irsend - basic LIRC program to send infra-red commands SYNOPSIS
irsend [options] DIRECTIVE REMOTE CODE [CODE...] DESCRIPTION
Asks the lircd daemon to send one or more CIR (Consumer Infra-Red) commands. This is intended for remote control of electronic devices such as TV boxes, HiFi sets, etc. DIRECTIVE can be: SEND_ONCE - send CODE [CODE ...] once SEND_START - start repeating CODE SEND_STOP - stop repeating CODE LIST - list configured remote items SET_TRANSMITTERS - set transmitters NUM [NUM ...] SIMULATE - simulate IR event REMOTE is the name of a remote, as described in the lircd configuration file. CODE is the name of a remote control key of REMOTE, as it appears in the lircd configuration file. NUM is the transmitter number of the hardware device. For the LIST DIRECTIVE, REMOTE and/or CODE can be empty: LIST "" "" - list all configured remote names LIST REMOTE "" - list all codes of REMOTE LIST REMOTE CODE - list only CODE of REMOTE The SIMULATE command only works if it has been explicitly enabled in lircd. -h --help display usage summary -v --version display version -d --device use given lircd socket [/var/run/lirc/lircd] -a --address=host[:port] connect to lircd at this address -# --count=n send command n times EXAMPLES
irsend LIST DenonTuner "" irsend SEND_ONCE DenonTuner PROG-SCAN irsend SEND_ONCE OnkyoAmpli VOL-UP VOL-UP VOL-UP VOL-UP irsend SEND_START OnkyoAmpli VOL-DOWN ; sleep 3 irsend SEND_STOP OnkyoAmpli VOL-DOWN irsend SET_TRANSMITTERS 1 irsend SET_TRANSMITTERS 1 3 4 irsend SIMULATE "0000000000000476 00 OK TECHNISAT_ST3004S" FILES
/etc/lirc/lircd.conf Default lircd configuration file. It should contain all the remotes, their infra-red codes and the corresponding timing and wave- form details. DIAGNOSTICS
If lircd is not running (or /var/run/lirc/lircd lacks write permissions) irsend aborts with the following diagnostics: "irsend: could not connect to socket" "irsend: Connection refused" (or "Permission denied"). SEE ALSO
The documentation for lirc is maintained as html pages. They are located under html/ in the documentation directory. lircd(8), mode2(1), smode2(1), xmode2(1), irrecord(1), irw(1), http://www.lirc.org. irsend 0.9.0-pre1 October 2010 IRSEND(1)
All times are GMT -4. The time now is 06:15 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy