Sponsored Content
Top Forums Shell Programming and Scripting Replacing Block of lines in a text file Post 302283265 by zaxxon on Tuesday 3rd of February 2009 02:02:10 AM
Old 02-03-2009
One possible way:
Code:
awk '/^Function3$/ { x=1 } /^param/ && x == 1 {print $1,($2+3); next} /^Function4$/ { x=0 } {print}' infile
Function1
{
parameter 1
parameter 2
parameter 3
}
end

Function2
{
parameter 1
parameter 2
parameter 3
}
end

Function3
{
parameter 4
parameter 5
parameter 6
}
end

Function4
{
parameter 1
parameter 2
parameter 3
}
end

 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

replacing first line or lines in a file

hey guys, how do i replace only a line within a file without messing up the rest of the contents of the file? see, if possible can you guys give me a straight forward way to do this. i dont want a complex command. what i mean is i know i can accomplish this by using sed, well, i think i can,... (3 Replies)
Discussion started by: Terrible
3 Replies

2. Shell Programming and Scripting

replacing specific lines in a file

Hi there I have a file which has the lines # Serial number for hostid EXP_SERIAL_="" These lines could be anywhere in the file as far as line numbers go, I would like replace these two lines with # Serial number for hostid $var1 EXP_SERIAL_$var1="$var2" Is there a quick and simple... (6 Replies)
Discussion started by: hcclnoodles
6 Replies

3. Shell Programming and Scripting

Replacing lines in text files

Hi, I have 2 sets of text files. I need to take a field from a certain line in set 1 and put it in the same place in set b. The line appears once per file, in different places but is a set format and has the unique word "ANTENNA" in it and is always 81 characters long. Example from set a: ... (7 Replies)
Discussion started by: Jonny2Vests
7 Replies

4. Shell Programming and Scripting

Replacing Text in Text file

Hi Guys, I am needing some help writing a shell script to replace the following in a text file /opt/was/apps/was61 with some other path eg /usr/blan/blah/blah. I know that i can do it using sed or perl but just having difficulty writing the escape characters for it All Help... (3 Replies)
Discussion started by: cgilchrist
3 Replies

5. Shell Programming and Scripting

replacing text in a file, but...

Hi all, Very first post on this forums, hope you can help me with this scripting task. I have a big text file with over 3000 lines, some of those lines contain some text that I need to replace, lets say for simplicity the text to be replaced in those lines is "aaa" and I need it to replace it... (2 Replies)
Discussion started by: Angelseph
2 Replies

6. Shell Programming and Scripting

sed: Replacing two lines of text

I just created a file in vi, looks like this: Hello nobody nobody What I need is to have sed change the file so it looks like this: Hello everybody In other words, the sed query needs to look for both instances of "nobody" before it puts the word "everybody" on the first line. ... (2 Replies)
Discussion started by: calrog
2 Replies

7. UNIX for Advanced & Expert Users

Move a block of lines to file if string found in the block.

I have a "main" file which has blocks of data for each user defined by tags BEGIN and END. BEGIN ID_NUM:24879 USER:abc123 HOW:47M CMD1:xyz1 CMD2:arp2 STATE:active PROCESS:id60 END BEGIN ID_NUM:24880 USER:def123 HOW:4M CMD1:xyz1 CMD2:xyz2 STATE:running PROCESS:id64 END (7 Replies)
Discussion started by: grep_me
7 Replies

8. Shell Programming and Scripting

Printing a block of lines from a file, if that block does not contain two patterns using sed

I want to process a file block by block using sed, and if that block does not contain two patterns, then that complete block has to be printed. See below for the example data. ................................server 1............................... running process 1 running... (8 Replies)
Discussion started by: Kesavan
8 Replies

9. Shell Programming and Scripting

Matching and Replacing file lines starting with $

Here is the task that I was presented with: I am dealing with about a 10,000 line input deck file for an analysis. About 10 separate blocks of around 25 lines of code each need to be updated in the input deck. The input deck (deckToChange in the code below) comes with 2 separate files. File 1... (5 Replies)
Discussion started by: tiktak292
5 Replies

10. Shell Programming and Scripting

Match text to lines in a file, iterate backwards until text or text substring matches, print to file

hi all, trying this using shell/bash with sed/awk/grep I have two files, one containing one column, the other containing multiple columns (comma delimited). file1.txt abc12345 def12345 ghi54321 ... file2.txt abc1,text1,texta abc,text2,textb def123,text3,textc gh,text4,textd... (6 Replies)
Discussion started by: shogun1970
6 Replies
PS_SHOW(3)								 1								PS_SHOW(3)

ps_show - Output text

SYNOPSIS
bool ps_show (resource $psdoc, string $text) DESCRIPTION
Output a text at the current text position. The text position can be set by storing the x and y coordinates into the values textx and texty with the function ps_set_value(3). The function will issue an error if a font was not set before with ps_setfont(3). ps_show(3) evaluates the following parameters and values as set by ps_set_parameter(3) and ps_set_value(3). o charspacing (value) - Distance between two consecutive glyphs. If this value is unequal to zero then all ligatures will be resolved. Values less than zero are allowed. o kerning (parameter) - Setting this parameter to "false" will turn off kerning. Kerning is turned on by default. o ligatures (parameter) - Setting this parameter to "false" will turn off the use of ligatures. Ligatures are turned on by default. o underline (parameter) - Setting this parameter to "true" will turn on underlining. Underlining is turned off by default. o overline (parameter) - Setting this parameter to "true" will turn on overlining. Overlining is turned off by default. o strikeout (parameter) - Setting this parameter to "true" will turn on striking out. Striking out is turned off by default. PARAMETERS
o $psdoc - Resource identifier of the postscript file as returned by ps_new(3). o $text - The text to be output. RETURN VALUES
Returns TRUE on success or FALSE on failure. SEE ALSO
ps_continue_text(3), ps_show_xy(3), ps_setfont(3). PHP Documentation Group PS_SHOW(3)
All times are GMT -4. The time now is 08:40 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy