Sponsored Content
Top Forums Shell Programming and Scripting Replace multiple lines through sed Post 302661483 by adgangwar on Monday 25th of June 2012 09:51:14 AM
Old 06-25-2012
Replace multiple lines through sed

Hi All,

I have a input file as sample below

Code:
<this is not starting of file>
record
line1
line2
line3
end
line4
line5
record
line6
line7
line8

my requirement is this, i want to select a pattern between first record and end, whatever is written between first record and end.
and i want to replace it with some different set of lines.
maybe like

expected output:
Code:
 <not starting of file>
record
line11
line12
line13
end
line4
line5
record
line6
line7
line8

Kindly, give me some idea , how to do that??

Thanks,
Aditya

Moderator's Comments:
Mod Comment Please use code tags, thanks!

Last edited by zaxxon; 06-25-2012 at 11:07 AM.. Reason: code tags, see PM
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

using sed command to replace multiple lines

the file contains the follwoing lines /* * Copyright (C) 1995-1996 by XXX Corporation. This program * contains proprietary and confidential information. All rights reserved * except as may be permitted by prior written consent. * * $Id: xxx_err.h,v 1.10 2001/07/26 18:48:34 zzzz $ ... (1 Reply)
Discussion started by: radha.kalivar
1 Replies

2. Shell Programming and Scripting

replace multiple lines in multiple files

i have to search a string and replace with multiple lines. example Input echo 'sample text' echo 'college days' output echo 'sample text' echo 'information on students' echo 'emp number' echo 'holidays' i have to search a word college and replace the multiple lines i have... (1 Reply)
Discussion started by: unihp1
1 Replies

3. Shell Programming and Scripting

sed find and replace multiple lines

I am new to linux and would like to modify the contents of a file preferably using a one line. The situation is as follows <start> some lines "I am the string" "replace string" more lines here <end> In the above example,On encountering "I am the string", the "replace string "should be... (6 Replies)
Discussion started by: supersimha
6 Replies

4. Shell Programming and Scripting

Replace multiple lines between tags using sed

I have a file example.txt with content look like this: <TAG> 1 2 3 </TAG> and I use a sed command to replace everything between <TAG></TAG> as below: sed -e 's/\(<TAG>\)*\(<.*\)/something/g' example.txt > example.txt.new But unfortunately, the command failed to replace as i want, it... (23 Replies)
Discussion started by: dollylamb
23 Replies

5. Shell Programming and Scripting

replace (sed?) a single line/string in file with multiple lines (string) from another file??

Can someone tell me how I can do this? e.g: Say file1.txt contains: today is monday the 22 of NOVEMBER 2010 and file2.txt contains: the 11th month of How do i replace the word NOVEMBER with (5 Replies)
Discussion started by: tuathan
5 Replies

6. Shell Programming and Scripting

replace (sed?) a string in file with multiple lines (string) from variable

Can someone tell me how I can do this? e.g: a=$(echo -e wert trewt ertert ertert ertert erttert erterte rterter tertertert ert) How do i replace the STRING with $a? I try this: sed -i 's/STRING/'"$a"'/g' filename.ext but this don' t work (2 Replies)
Discussion started by: jforce
2 Replies

7. Shell Programming and Scripting

search and replace, when found, delete multiple lines, add new set of lines?

hey guys, I tried searching but most 'search and replace' questions are related to one liners. Say I have a file to be replaced that has the following: $ cat testing.txt TESTING AAA BBB CCC DDD EEE FFF GGG HHH ENDTESTING This is the input file: (3 Replies)
Discussion started by: DeuceLee
3 Replies

8. Shell Programming and Scripting

Find and replace multiple lines

I have a section of text in file A, see below # falkdjf lkjadf lkjadf lkajdf lkajdf lkajdf lkjadf lkjadf 234.234.2.234 lkjlkjlk 234.234.3.234 # Only the first line with "# falkdjf lkjadf lkjadf" is unique in the file. The new section that I want to overwrite the old section above is in... (1 Reply)
Discussion started by: jyang72211
1 Replies

9. 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

10. Shell Programming and Scripting

Sed/awk/perl command to replace pattern in multiple lines

Hi I know sed and awk has options to give range of line numbers, but I need to replace pattern in specific lines Something like sed -e '1s,14s,26s/pattern/new pattern/' file name Can somebody help me in this.... I am fine with see/awk/perl Thank you in advance (9 Replies)
Discussion started by: dani777
9 Replies
SYNCTEX(5)						      BSD File Formats Manual							SYNCTEX(5)

NAME
synctex -- Synchronize TeXnology help file DESCRIPTION
Synchronize TeXnology help file (synctexs) are text files that help input/output synchronization during document preparation with the TeX typesetting system. BASICS
The structure of this file should not be considered public, in the sense that no one should need to parse its contents, except the synctex command line utility, and the synctex_parser library. Unless it is absolutely not avoidable, access to the contents of the synctex file should only be made through requests made to the synctex command line utility. STRUCTURE
The element structure of a synctex file is a list of text line records as follows. '*', '+', and '?' have their usual EBNF meanings: '*' means zero or more, '+' means one or more, and '?' means zero or one (i.e., optional). <SyncTeX> ::= (The whole contents in 4 sections) <Preamble> <Content> <Postamble> <Post Scriptum> Each section starts with the first occurrence of a sectioning line, and ends with the next section, if any. In the following definitions, we do not mention the section ending condition. The preamble <Preamble> ::= "SyncTeX Version:" <Version Number> <EOL> <Input Line>* "Magnification:" <TeX magnification> <EOL> "Unit:" <unit in scaled point> <EOL> "X Offset:" <horizontal offset in scaled point> <EOL> "Y Offset:" <vertical offset in scaled point> <EOL> <Input Line> ::= "Input:" <tag> ":" <File Name> <EOL> The content <Content> ::= <byte offset record> "Content:" <EOL> <sheet(1)> <Input Line>* <sheet(2)> <Input Line>* ... <sheet(N)> <Input Line>* <byte offset record> ::= "!" <byte offset> <end of record> <sheet(n)> ::= <byte offset record> "{" <the integer n> <end of record>/ <box content>* <byte offset record> "}" <the integer n> <end of record> The <box content> describes what is inside a box. It is either a vertical or horizontal box, with some records related to glue, kern or math nodes. <box content> ::= <vbox section>|<hbox section> |<void vbox record>|<void hbox record> |<current record>|<glue record>|<kern record>|<math record> <vbox section> ::= "[" <link> ":" <point> ":" <size> <end of record> <box content>* "]" <end of record> <hbox section> ::= ( <link> ":" <point> ":" <size> <end of record> <box content>* ")" <end of record> Void boxes: <void vbox record> ::= "v" <link> ":" <point> ":" <size> <end of record> <void hbox record> ::= "h" <link> ":" <point> ":" <size> <end of record> <size> ::= <Width> "," <Height> "," <Depth> <Width> ::= <integer> <Height> ::= <integer> <Depth> ::= <integer> <link> ::= <tag> "," <line>( "," <column>)? <line> ::= <integer> <column> ::= <integer> The forthcoming records are basic one liners. <current record> ::= "x" <link> ":" <point> <end of record> <kern record> ::= "k" <link> ":" <point> ":" <Width> <end of record> <glue record> ::= "g" <link> ":" <point> <end of record> <math record> ::= "$" <link> ":" <point> <end of record> The postamble The postamble closes the file If there is no postamble, it means that the typesetting process did not end correctly. <Postamble>::= <byte offset record> "Count:" <Number of records> <EOL> The post scriptum The post scriptum contains material possibly added by 3rd parties. It allows to append some transformation (shift and magnify). Typically, one applies a dvi to pdf filter with offset options and magnification, then he appends the same options to the synctex file, for example synctex update -o foo.pdf -m 0.486 -x 9472573sp -y 13.3dd source.dvi <Post Scriptum>::= <byte offset record> "Post Scriptum:" <EOL> "Magnification:" <number> <EOL> (Set additional magnification) "X Offset:" <dimension> <EOL> (Set horizontal offset) "Y Offset:" <dimension> <EOL> (Set vertical offset) This second information will override the offset and magnification previously available in the preamble section. All the numbers are encoded using the decimal representation with "C" locale. USAGE
The <current record> is used to compute the visible size of hbox's. The byte offset is an implicit anchor to navigate the synctex file from sheet to sheet. Independant Mar 13, 2012 Independant
All times are GMT -4. The time now is 06:26 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy