Sponsored Content
Full Discussion: Copy pattern inside the file
Top Forums UNIX for Beginners Questions & Answers Copy pattern inside the file Post 303014929 by arunkumar_mca on Friday 23rd of March 2018 02:36:31 PM
Old 03-23-2018
Copy pattern inside the file

Hi all,

I have files and have a missing record. I need copy the existing record and mark those values up. For example in the below file 11048 is missing. I need to copy 22001 and copy those create the values for 11048. I have 120 set of files and I need to do that on all files.

Note the only ID I am missing is 11048 and I have to copy the 22001 to it. There are 120 files I have to do which will be on name file1,file2 ----file120



File 1
Code:
11047;1;292;;;;;;;111.21;;;;;;;;;;;;;;;;;;;;;;;;;;
11047;2;292;;;;;;;111.21;;;;;;;;;;;;;;;;;;;;;;;;;;
11047;3;292;;;;;;;111.21;;;;;;;;;;;;;;;;;;;;;;;;;;
22001;1;292;;;;;;;8672148.20;;;;;;;;;;;;;;;;;;;;;;;;;;
22001;2;292;;;;;;;2393827.87;;;;;;;;;;;;;;;;;;;;;;;;;;
22001;3;292;;;;;;;212731.80;;;;;;;;;;;;;;;;;;;;;;;;;;
22001;5;292;;;;;;;1127146.04;;;;;;;;;;;;;;;;;;;;;;;;;;
22002;1;292;;;;;;;3255450.44;;;;;;;;;;;;;;;;;;;;;;;;;;
22002;2;292;;;;;;;878702.70;;;;;;;;;;;;;;;;;;;;;;;;;;
22002;3;292;;;;;;;85449.23;;;;;;;;;;;;;;;;;;;;;;;;;;

Expected File1

Code:
11047;1;292;;;;;;;111.21;;;;;;;;;;;;;;;;;;;;;;;;;;
11047;2;292;;;;;;;111.21;;;;;;;;;;;;;;;;;;;;;;;;;;
11047;3;292;;;;;;;111.21;;;;;;;;;;;;;;;;;;;;;;;;;;
11048;1;292;;;;;;;8672148.20;;;;;;;;;;;;;;;;;;;;;;;;;;
11048;2;292;;;;;;;2393827.87;;;;;;;;;;;;;;;;;;;;;;;;;;
11048;3;292;;;;;;;212731.80;;;;;;;;;;;;;;;;;;;;;;;;;;
11048;5;292;;;;;;;1127146.04;;;;;;;;;;;;;;;;;;;;;;;;;;
22001;1;292;;;;;;;8672148.20;;;;;;;;;;;;;;;;;;;;;;;;;;
22001;2;292;;;;;;;2393827.87;;;;;;;;;;;;;;;;;;;;;;;;;;
22001;3;292;;;;;;;212731.80;;;;;;;;;;;;;;;;;;;;;;;;;;
22001;5;292;;;;;;;1127146.04;;;;;;;;;;;;;;;;;;;;;;;;;;
22002;1;292;;;;;;;3255450.44;;;;;;;;;;;;;;;;;;;;;;;;;;
22002;2;292;;;;;;;878702.70;;;;;;;;;;;;;;;;;;;;;;;;;;
22002;3;292;;;;;;;85449.23;;;;;;;;;;;;;;;;;;;;;;;;;;


Last edited by arunkumar_mca; 03-24-2018 at 12:04 AM.. Reason: Added more details
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to search a pattern inside a zipped file ie (.gz file) with out unzipping it

How to search a pattern inside a zipped file ie (.gz file) with out unzipping it? using grep command.. Bit urgent.. pls..help me (2 Replies)
Discussion started by: senraj01
2 Replies

2. Shell Programming and Scripting

Need help in sed command ( Replacing a pattern inside a file with a variable value )

Hello, The following sed command is giving error sed: -e expression #1, char 13: unknown option to `s' The sed command is echo "//-----" | sed "s/\/\/---*/$parChk/g" where parChk="//---ee-" How can i print the variable value from sed command ? And is it possible to replace a... (2 Replies)
Discussion started by: frozensmilz
2 Replies

3. Shell Programming and Scripting

pattern replace inside text file using sed

Hi, I have a situation where I want to replace some occurrences of ".jsp" into ".html" inside a text file. For Example: If a pattern found like <a href="http://www.mysite.com/mypage.jsp"> it should be retained. But if a pattern found like <a href="../mypage.jsp"> it should be changed to... (4 Replies)
Discussion started by: meharo
4 Replies

4. Shell Programming and Scripting

how to find the pattern inside the file and replace it

hello everybody, I have a group of file eg- sample1 sample2 sample3 sample4 each file contain this :- cat sample1 SEQ_NUM,1,UPESI1 My requirement is to change the value-UPESI1 to UPE10 in file which contain this pattern -UPESI1. any help is appreciated. (2 Replies)
Discussion started by: abhigrkist
2 Replies

5. Homework & Coursework Questions

copy files inside a text file

Hi Guys , I am new to this and Hi to all ,Need your help I am trying to copy Files which are inside file.txt The files inside file.txt are inthe below order file1.log file2.log file3.log ....... I want to copy these files to an output Directory , Please help (1 Reply)
Discussion started by: hc17972
1 Replies

6. Homework & Coursework Questions

copy files inside a text file

Hi Guys , I am new to this and Hi to all ,Need your help I am trying to copy Files which are inside file.txt The files inside file.txt are inthe below order file1.log file2.log file3.log ....... I want to copy these files to an output Directory , Please help (1 Reply)
Discussion started by: hc17972
1 Replies

7. Shell Programming and Scripting

Help with matching pattern inside a file

I have a huge file that has roughly 30304 lines. I need to extract specific info from that file. For example, Box 1 > *aaaaaaaajjjj* > hbbvjvj > jdnnfddllll > *dgdfhfekwjh* Box 2 > *aaaaaaa'aj'jjj* > dse hkjuejef bfdw > dyeee > dsewq > *dgdfhfekwjh* >feweiuei Box 3 > *aaaa"aaaaj"jjj* >... (25 Replies)
Discussion started by: Ernst
25 Replies

8. Shell Programming and Scripting

Finding the pattern and replacing the pattern inside the file

i have little challenge, help me out.i have a file where i have a value declared and and i have to replace the value when called. for example i have the value for abc and ccc. now i have to substitute the value of value abc and ccc in the place of them. Input File: go to &abc=ddd; if... (16 Replies)
Discussion started by: saaisiva
16 Replies

9. Shell Programming and Scripting

Copy and paste text inside a xml file

I have a really big XML file. I need copy the value of one tag inside another one tag. I try to publish one example. <channel update="i" site="merge-xmltv" site_id="" xmltv_id="Rai 1">Rai 1</channel> <channel update="i" site="merge-xmltv" site_id="" xmltv_id="Rai 1 +2HD">Rai 1... (6 Replies)
Discussion started by: Tapiocapioca
6 Replies

10. UNIX for Beginners Questions & Answers

Search a string inside a pattern matched block of a file

How to grep for searching a string within a begin and end pattern of a file. Sent from my Redmi 3S using Tapatalk (8 Replies)
Discussion started by: Baishali
8 Replies
YAML_EMIT(3)								 1							      YAML_EMIT(3)

yaml_emit - Returns the YAML representation of a value

SYNOPSIS
string yaml_emit (mixed $data, [int $encoding = YAML_ANY_ENCODING], [int $linebreak = YAML_ANY_BREAK], [array $callbacks]) DESCRIPTION
Generate a YAML representation of the provided $data. PARAMETERS
o $data - The $data being encoded. Can be any type except a resource. o $encoding - Output character encoding chosen from YAML_ANY_ENCODING, YAML_UTF8_ENCODING, YAML_UTF16LE_ENCODING, YAML_UTF16BE_ENCODING. o $linebreak - Output linebreak style chosen from YAML_ANY_BREAK, YAML_CR_BREAK, YAML_LN_BREAK, YAML_CRLN_BREAK. o $callbacks - Content handlers for emitting YAML nodes. Associative array of classname => callable mappings. See emit callbacks for more details. RETURN VALUES
Returns a YAML encoded string on success. CHANGELOG
+--------+--------------------------------------+ |Version | | | | | | | Description | | | | +--------+--------------------------------------+ | 1.1.0 | | | | | | | The $callbacks parameter was added. | | | | +--------+--------------------------------------+ EXAMPLES
Example #1 yaml_emit(3) example <?php $addr = array( "given" => "Chris", "family"=> "Dumars", "address"=> array( "lines"=> "458 Walkman Dr. Suite #292", "city"=> "Royal Oak", "state"=> "MI", "postal"=> 48046, ), ); $invoice = array ( "invoice"=> 34843, "date"=> 980208000, "bill-to"=> $addr, "ship-to"=> $addr, "product"=> array( array( "sku"=> "BL394D", "quantity"=> 4, "description"=> "Basketball", "price"=> 450, ), array( "sku"=> "BL4438H", "quantity"=> 1, "description"=> "Super Hoop", "price"=> 2392, ), ), "tax"=> 251.42, "total"=> 4443.52, "comments"=> "Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338.", ); var_dump(yaml_emit($invoice)); ?> The above example will output something similar to: string(628) "--- invoice: 34843 date: 980208000 bill-to: given: Chris family: Dumars address: lines: |- 458 Walkman Dr. Suite #292 city: Royal Oak state: MI postal: 48046 ship-to: given: Chris family: Dumars address: lines: |- 458 Walkman Dr. Suite #292 city: Royal Oak state: MI postal: 48046 product: - sku: BL394D quantity: 4 description: Basketball price: 450 - sku: BL4438H quantity: 1 description: Super Hoop price: 2392 tax: 251.420000 total: 4443.520000 comments: Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338. " SEE ALSO
yaml_emit_file(3), yaml_parse(3). PHP Documentation Group YAML_EMIT(3)
All times are GMT -4. The time now is 10:39 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy