Sponsored Content
Top Forums Shell Programming and Scripting [sed]: Substitute a string with a multiline value Post 302978675 by rdrtx1 on Tuesday 2nd of August 2016 01:02:04 PM
Old 08-02-2016
Code:
while read line
do
   if [ "$line" = "@InputFlowDef" ]
   then
     echo "$Myvar"
   else
     echo "$line"
   fi
done < MyFile.txt

This User Gave Thanks to rdrtx1 For This Post:
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

delete multiline string from file using sed.

Hi, I have file which has the following content... GOOD MORNING **********WARNING********** when it kicks from the kickstart, sshd daemon should start at last. (WHEN KICKING ITSELF, NOT AFTER KICKING). /etc/rc3.d/S55sshd ( run level specification for sshd is 55, now I would want to... (4 Replies)
Discussion started by: skmdu
4 Replies

2. Shell Programming and Scripting

Multiline pattern search using sed or awk

Hi friends, Could you please help me to resolve the below issue. Input file :- <Node> <username>abc</username> <password>ABC</password> <Node> <Node> <username>xyz</username> <password>XYZ</password> <Node> <Node> <username>mnp</username> ... (3 Replies)
Discussion started by: haiksuresh
3 Replies

3. UNIX for Dummies Questions & Answers

Reading one line from a multiline string

Hi , I have a string which is of multiple line,I have to split the string by reading one line in each iteration and keep it in a string.I am keeping all the file names in side as string returned by the ls command ,I am stocked at the point of spliting the string to segragate each file. ... (4 Replies)
Discussion started by: Deekay.p
4 Replies

4. Shell Programming and Scripting

sed doubt - search and substitute string from variable.

hi, trying to learn more abt sed :( i want to substitute a variable(a) with other variable(b) appended. Read.txt contains: home/test2/abc home/test/root1 input.txt contains: make test "home/test1/none"version="1.3" wt's wrong test "home/test2/abc"version="1.0" make save... (9 Replies)
Discussion started by: dragon.1431
9 Replies

5. UNIX for Dummies Questions & Answers

sed multiline pattern match

How can I write a script that takes a cisco config file and outputs every occurrence of two, or more, pattern matches through the whole config file? For example, out of a config file, i want to print out every line with interface, description and ip address through the whole file, and disregard... (3 Replies)
Discussion started by: knownasthatguy
3 Replies

6. Shell Programming and Scripting

{bash scripting} Multiline initialisation of string variable

Hello, The task is quite simple. I need to initialise а string variable and assign to it a very long value. For the reason of readability I want to devide this long value into equal parts and place each part at a separate line. For instance, I have - ... (1 Reply)
Discussion started by: Pretoria
1 Replies

7. UNIX for Dummies Questions & Answers

Need Multiline sed help!!

Hey everyone, I'm new to sed and I need to create a script for inserting one line of code at the beginning of every method in a Xcode project (over 6,000 methods). Each method Structure is (+ or -) (Various declarations-- could span multiple lines) ({) I've tried for days, any guidance would be... (2 Replies)
Discussion started by: jimmyz
2 Replies

8. Shell Programming and Scripting

Multiline sed

Hi guys, I am fairly comfortable with using the sed command if the string to be replaced is all on a single line. I was wondering is it possible to use sed command in a multiline way ? Say for example I have the below string on 2 different lines: { "key": "brandNameA", ... (3 Replies)
Discussion started by: Junaid Subhani
3 Replies

9. Shell Programming and Scripting

sed multiline problem

I'm trying to replicate the sed output on p.108 of Sed&Awk,by Doughery & Robbins, 2nd edition. I'm on a Windows 10 Surface Pro, running Cygwin for 64-bit versions of Windows. Input text saved in text file called data_p108.txt: Consult Section 3.1 in the Owner and Operator Guide for a... (9 Replies)
Discussion started by: prooney
9 Replies
ROUND(3)								 1								  ROUND(3)

round - Rounds a float

SYNOPSIS
float round (float $val, [int $precision], [int $mode = PHP_ROUND_HALF_UP]) DESCRIPTION
Returns the rounded value of $val to specified $precision (number of digits after the decimal point). $precision can also be negative or zero (default). Note PHP doesn't handle strings like "12,300.2" correctly by default. See converting from strings. PARAMETERS
o $val - The value to round o $precision - The optional number of decimal digits to round to. o $mode - Use one of the following constants to specify the mode in which rounding occurs. +--------------------+---------------------------------------------------+ | Constant | | | | | | | Description | | | | +--------------------+---------------------------------------------------+ | | | | PHP_ROUND_HALF_UP | | | | | | | Round $val up to $precision decimal places away | | | from zero, when it is half way there. Making 1.5 | | | into 2 and -1.5 into -2. | | | | | | | |PHP_ROUND_HALF_DOWN | | | | | | | Round $val down to $precision decimal places | | | towards zero, when it is half way there. Making | | | 1.5 into 1 and -1.5 into -1. | | | | | | | |PHP_ROUND_HALF_EVEN | | | | | | | Round $val to $precision decimal places towards | | | the next even value. | | | | | | | |PHP_ROUND_HALF_ODD | | | | | | | Round $val to $precision decimal places towards | | | the next odd value. | | | | +--------------------+---------------------------------------------------+ RETURN VALUES
The rounded value EXAMPLES
Example #1 round(3) examples <?php echo round(3.4); // 3 echo round(3.5); // 4 echo round(3.6); // 4 echo round(3.6, 0); // 4 echo round(1.95583, 2); // 1.96 echo round(1241757, -3); // 1242000 echo round(5.045, 2); // 5.05 echo round(5.055, 2); // 5.06 ?> Example #2 $mode examples <?php echo round(9.5, 0, PHP_ROUND_HALF_UP); // 10 echo round(9.5, 0, PHP_ROUND_HALF_DOWN); // 9 echo round(9.5, 0, PHP_ROUND_HALF_EVEN); // 10 echo round(9.5, 0, PHP_ROUND_HALF_ODD); // 9 echo round(8.5, 0, PHP_ROUND_HALF_UP); // 9 echo round(8.5, 0, PHP_ROUND_HALF_DOWN); // 8 echo round(8.5, 0, PHP_ROUND_HALF_EVEN); // 8 echo round(8.5, 0, PHP_ROUND_HALF_ODD); // 9 ?> Example #3 $mode with precision examples <?php /* Using PHP_ROUND_HALF_UP with 1 decimal digit precision */ echo round( 1.55, 1, PHP_ROUND_HALF_UP); // 1.6 echo round( 1.54, 1, PHP_ROUND_HALF_UP); // 1.5 echo round(-1.55, 1, PHP_ROUND_HALF_UP); // -1.6 echo round(-1.54, 1, PHP_ROUND_HALF_UP); // -1.5 /* Using PHP_ROUND_HALF_DOWN with 1 decimal digit precision */ echo round( 1.55, 1, PHP_ROUND_HALF_DOWN); // 1.5 echo round( 1.54, 1, PHP_ROUND_HALF_DOWN); // 1.5 echo round(-1.55, 1, PHP_ROUND_HALF_DOWN); // -1.5 echo round(-1.54, 1, PHP_ROUND_HALF_DOWN); // -1.5 /* Using PHP_ROUND_HALF_EVEN with 1 decimal digit precision */ echo round( 1.55, 1, PHP_ROUND_HALF_EVEN); // 1.6 echo round( 1.54, 1, PHP_ROUND_HALF_EVEN); // 1.5 echo round(-1.55, 1, PHP_ROUND_HALF_EVEN); // -1.6 echo round(-1.54, 1, PHP_ROUND_HALF_EVEN); // -1.5 /* Using PHP_ROUND_HALF_ODD with 1 decimal digit precision */ echo round( 1.55, 1, PHP_ROUND_HALF_ODD); // 1.5 echo round( 1.54, 1, PHP_ROUND_HALF_ODD); // 1.5 echo round(-1.55, 1, PHP_ROUND_HALF_ODD); // -1.5 echo round(-1.54, 1, PHP_ROUND_HALF_ODD); // -1.5 ?> CHANGELOG
+--------+---------------------------------------------------+ |Version | | | | | | | Description | | | | +--------+---------------------------------------------------+ | 5.3.0 | | | | | | | The $mode parameter was introduced. | | | | | 5.2.7 | | | | | | | The inner workings of round(3) was changed to | | | conform to the C99 standard. | | | | +--------+---------------------------------------------------+ SEE ALSO
ceil(3), floor(3), number_format(3). PHP Documentation Group ROUND(3)
All times are GMT -4. The time now is 01:08 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy