Sponsored Content
Top Forums Shell Programming and Scripting Search for a value and replace other field in the same set Post 302879971 by Chubler_XL on Monday 16th of December 2013 09:02:15 PM
Old 12-16-2013
try this script:

Code:
infile=$1
val="$2"
new="$3"
awk -vv="$val" -vn="$new" '
$0 ~ "VALUE \"" v "\"" {
    gsub("[[]Result[^\n]*\n", "[Result \"" n "\"]\n")
}
1' RS='' ORS='\n\n' OFS='\n' $infile

This User Gave Thanks to Chubler_XL For This Post:
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

vi search/replace using a set

Hi, I'm trying to do a global search/replace in vi using a set - I want to find every occurance of a carriage return followed by a character and replace it with a space. I've tried the following: :%s/\n/ /g It does the search ok, but it replaces the characters with the literal value ""... (2 Replies)
Discussion started by: HudZo
2 Replies

2. Shell Programming and Scripting

awk search and replace field

I am writing a c++ program that has many calls of pow(input,2). I now realize that this is slowing down the program and these all should be input * input for greater speed. There should be a simple way of doing this replacement throughout my file with awk, but I am not very familiar with awk.... (2 Replies)
Discussion started by: bluejayek
2 Replies

3. Shell Programming and Scripting

Perl - search and replace a particular field

Hi, I have a file having around 30 records. Each record has 5 fields delimited by PIPE. Few records in the file having Junk characters in the field2 and field4. I found the junk charcter and I tested it and replace the junk with space with the command below perl -i -p -e "s/\x00/ /g"... (1 Reply)
Discussion started by: ramkrix
1 Replies

4. Shell Programming and Scripting

Search duplicate field and replace one of them with new value

Dear All, I have file with 4 columns: 1 AA 0 21 2 BB 0 31 3 AA 0 21 4 CC 0 41 I would like to find the duplicate record based on column 2 and replace the 4th column of the duplicate by a new value. So, the output will be: 1 AA 0 21 2 BB 0 31 3 AA 0 -21 4 CC 0 41 Any suggestions... (3 Replies)
Discussion started by: ezhil01
3 Replies

5. Shell Programming and Scripting

Search and replace field?

I have 2 files A.txt and B.txt A.txt 3 fields and separate by a comma some,thing,florida any1,thing1,california some2,thing2,dallas just,fun,kansas B.txt has 8 fields and separate by a comma what,ever,florida-state,,,,,, some,one,dallas_state,,,,,, You will see 3rd fields are the... (5 Replies)
Discussion started by: sabercats
5 Replies

6. Shell Programming and Scripting

awk search and replace in a targeted field instead of $0

Hi I would like to apply this gawk command: gawk '{$0=gensub(/\y+\y/,"","g"); print}' file not to the whole $0 but just to the part of $0 that is between: (a number)"> and </mrk> Is it possible? thanks for your help. (4 Replies)
Discussion started by: louisJ
4 Replies

7. Shell Programming and Scripting

Search field in text file and replace value

Hi there, First of all this is my first post here. Thank you in advance for your help. What I am trying to do is the following. I have a text file where each field of each row is separated by a tabulator. Looks like this: ATOM 1 N HSE A 26 3.033 -10.429 -2.262 1.00 17.07 ... (8 Replies)
Discussion started by: doom4
8 Replies

8. UNIX for Dummies Questions & Answers

Search and replace the last field

Hi All, Seeking for your assistance on how to search and replace the last field/column. please see sample below: inputfile1.csv ="8923523434",="543623534"="afd23535623",="100"="200" ="8923523431",="543623536"="afd23535626",="101"="201"... (3 Replies)
Discussion started by: poginiks
3 Replies

9. Shell Programming and Scripting

Help needed with shell script to search and replace a set of strings among the set of files

Hi, I am looking for a shell script which serves the below purpose. Please find below the algorithm for the same and any help on this would be highly appreciated. 1)set of strings need to be replaced among set of files(directory may contain different types of files) 2)It should search for... (10 Replies)
Discussion started by: Amulya
10 Replies
MojoMojo::Schema::Result::PageVersion(3pm)		User Contributed Perl Documentation		MojoMojo::Schema::Result::PageVersion(3pm)

NAME
MojoMojo::Schema::Result::PageVersion - Versioned page metadata DESCRIPTION
This table implements versioning of page metadata (not content, see MojoMojo::Schema::Result::Content for that). It has a composite primary key "(page, version)". When renaming a page, a new version is created in this table, with "version" set to 1 + the maximum version for that "page". The "status" of the new "page_version" is set to "released", its "release_date" is set to "DateTime->now", while the old "page_version"'s status is set to 'removed' and its "remove_date" is set to "DateTime->now". TODO o document the relationships o in order to support proper rollback, meaning creating a new version for the rollback operation itself, a "content_version" field needs to be added. o "created" is apparently unused: set to 0 for pages populated when creating the database, and NULL for all normal pages. METHODS
latest_version Return the PageVersion object having the latest version of this page. AUTHOR
Marcus Ramberg <mramberg@cpan.org> LICENSE
This library is free software. You can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2010-04-07 MojoMojo::Schema::Result::PageVersion(3pm)
All times are GMT -4. The time now is 01:30 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy