Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Changing array of data by sed Post 303044769 by teefa14 on Tuesday 3rd of March 2020 03:02:10 PM
Old 03-03-2020
Changing array of data by sed

Hi all,
Hope you are fine all

I want to change a certain field in specific array for example I got a file like below:

Code:
<alarmsend>yes</alarmsend>
<server>Hajk</server>
<type>5</type>
<alarmsend>yes</alarmsend>
<server>Hajk</server>
<type>1</type>
<alarmsend>yes</alarmsend>
<server>Hajk</server>
<type>3</type>
<alarmsend>yes</alarmsend>
<server>Hajk</server>
<type>5</type>


So I want to change alarm send to No for all type 5 for example to get out put as below

Code:
<alarmsend>no</alarmsend>
<server>Hajk</server>
<type>5</type>
<alarmsend>yes</alarmsend>
<server>Hajk</server>
<type>1</type>
<alarmsend>yes</alarmsend>
<server>Hajk</server>
<type>3</type>
<alarmsend>no</alarmsend>
<server>Hajk</server>
<type>5</type>


Thanks in advance
Moderator's Comments:
Mod Comment
Please use code tags when posting data and code samples!

Last edited by vgersh99; 03-03-2020 at 04:31 PM.. Reason: code tags, please!
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Changing text with sed?

Hi everyone, Having trouble with sed. I searched the board and found some stuff, but still unclear. I have a file named "userfile" which stores the users info in this form: email:username:password: I want the user to be able to change their password. i tried with sed s/oldpass/newpass/g... (2 Replies)
Discussion started by: primal
2 Replies

2. Shell Programming and Scripting

Changing Special Characters Using Sed

Hi. Does anyone know how to use the sed command to change the special border characters on this .per file. I have to edit about 80 .per files. I need a sed script to change the below 3 and A characters. ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ Test Islands, Office of Public Health -- WIC... (4 Replies)
Discussion started by: cstovall
4 Replies

3. UNIX for Dummies Questions & Answers

Changing the order using sed

I have a text "abc def ghi" and I want to get it as "def abc ghi" I am using this echo "abc def ghi" | sed 's/\(*\)\(*\)/\2\1/' But I am not able to get the output, could anyone help me. Thanks (9 Replies)
Discussion started by: venu_nbk
9 Replies

4. Shell Programming and Scripting

sed and changing the file itself

hello I have this: sed -e "s/install_location=....../g" -e "s/hostname=....../g" -e "s/server_name=....../y" input.txt it will display on the screen what have changed. however I want to change file input.txt. Any idea other than doing redirection (>) thx (2 Replies)
Discussion started by: melanie_pfefer
2 Replies

5. UNIX for Dummies Questions & Answers

changing data into matrix form

Hi, I have a file whose structure is like this 7 7 1 2 3 4 5 1 3 4 8 6 1 4 5 6 0 2 6 8 3 8 2 5 7 8 0 5 7 9 4 1 3 8 0 2 2 3 5 6 8 basically first two row tell the number of rows and column but the data following them are not arranged in that format. now i want to create another... (1 Reply)
Discussion started by: g0600014
1 Replies

6. Shell Programming and Scripting

changing c comments to c++ style with sed

Hi everyone, I've got a problem with converting C comments ( /* */ ) into C++ style ( // ) in some source file with sed. So far I've dealt with comments on one line, but I don't know how to convert when it is over multiple lines ... So I already have something like this: comments.sed ... (8 Replies)
Discussion started by: kolage
8 Replies

7. UNIX for Dummies Questions & Answers

Changing Text with sed or awk

I'm changing some html code on multiple web pages and I need to match particular phrases but keep some text within each phrase. E.G. I need to change this line: <DIV id="heading">Description:</DIV> into <span class="hlred">Description:</span><br /> The text "Description:" may... (2 Replies)
Discussion started by: hal8000
2 Replies

8. Shell Programming and Scripting

sed/awk changing values

Can somebody help me out and provide me with a SED or AWK solution that converts TO_DATE CLAUSE -> TIMESTAMP I need to keep the PARTION value (HISTORY_20110417) and DATE/TIME value (2011-04-18 00:00:00) the same for every line PARTITION HISTORY_20110417 VALUES LESS THAN (TO_DATE('... (3 Replies)
Discussion started by: BeefStu
3 Replies

9. UNIX for Dummies Questions & Answers

Changing data format from column into array

I have a file containing numbers in a column like: 10.5 16.3 15.7 2.3 46.8 3.3 . . . and I was wondering if there was a way to make it show up in an array form like: 10.5 2.3 16.3 46.8 15.7 3.3 Let's say I want to make a new column every 100 values. How can I do... (8 Replies)
Discussion started by: ShiGua
8 Replies

10. UNIX for Beginners Questions & Answers

Changing array of data by sed

Hi all, Hope you are fine all I want to change a certain field in specific array for example I got a file like below: <alarmsend>yes</alarmsend> <server>Hajk</server> <type>5</type> <alarmsend>yes</alarmsend> <server>Hajk</server> <type>1</type> <alarmsend>yes</alarmsend>... (6 Replies)
Discussion started by: teefa14
6 Replies
PX_CREATE_FP(3) 														   PX_CREATE_FP(3)

px_create_fp - Create a new paradox database

SYNOPSIS
bool px_create_fp (resource $pxdoc, resource $file, array $fielddesc) DESCRIPTION
Create a new paradox database file. The actual file has to be opened before with fopen(3). Make sure the file is writable. Note Calling this functions issues a warning about an empty tablename which can be safely ignored. Just set the tablename afterwards with px_set_parameter(3). Note This function is highly experimental, due to insufficient documentation of the paradox file format. Database files created with this function can be opened by px_open_fp(3) and has been successfully opened by the Paradox software, but your milage may vary. PARAMETERS
o $pxdoc - Resource identifier of the paradox database as returned by px_new(3). o $file -File handle as returned by fopen(3). o $fielddesc - fielddesc is an array containing one element for each field specification. A field specification is an array itself with either two or three elements.The first element is always a string value used as the name of the field. It may not be larger than ten characters. The second element contains the field type which is one of the constants listed in the table Constants for field types. In the case of a character field or bcd field, you will have to provide a third element specifying the length respectively the precesion of the field. If your field specification contains blob fields, you will have to make sure to either make the field large enough for all field values to fit or specify a blob file with px_set_blob_file(3) for storing the blobs. If this is not done the field data is truncated. RETURN VALUES
Returns TRUE on success or FALSE on failure. EXAMPLES
Example #1 Creating a Paradox database with two fields <?php if(!$pxdoc = px_new()) { /* Error handling */ } $fp = fopen("test.db", "w+"); $fields = array(array("col1", "S"), array("col2", "I")); if(!px_create_fp($pxdoc, $fp, $fields)) { /* Error handling */ } px_set_parameter($pxdoc, "tablename", "testtable"); for($i=-50; $i<50; $i++) { $rec = array($i, -$i); px_put_record($pxdoc, $rec); } px_close($pxdoc); px_delete($pxdoc); fclose($fp); ?> SEE ALSO
px_new(3), px_put_record(3), fopen(3). PHP Documentation Group PX_CREATE_FP(3)
All times are GMT -4. The time now is 07:59 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy