Replace field in one file with whole record data of another
Hello Group,
I need to replace the city field in “File 1 (fileld 3), with the entire record line of “File 2” (including delimiters) where the “city” field (File 1, Field 3)matches city field (File 2, Field1). All of the other data in “File 1” should remain intact(Fields 1,2,4,5,6). Only field 3 gets replaced.
First I need to convert “File 2” to have only the first letter of each word capitalized. I know I can:
to get everything to lower case but I am lost after that to convert back just the first alphabetic character in each word, in each field of “File 2” to capitals.
Here is the sample data I need to convert below:
File1:
File2:
So with that said the result of conversion of “File 2” + replacing field 3 in “File” should ultimately look like the below (Newfile).
Newfile:
I know most likely this is another job for “awk” but I am way out of practice.
Thanks in advance for any replies!
Art
Last edited by Scrutinizer; 05-06-2012 at 02:24 AM..
Reason: code tags
It think perl or GNU sed are more suited for uppercase / lowercase conversion. Give this try:
This is assuming that the leading space in the files is not there in reality. This can be done in regular awk, but that leads to elaborate code. This can also be combined in one Perl, but I think this might do...
Last edited by Scrutinizer; 05-06-2012 at 03:48 AM..
Each record coming with column names. I have to replace them in each record as shown below
TIME=20181219110000261|CHAN=FMBKHJBAAAADPCFNAAAAAABA|EVNT=SWIclst|VALU=Session FMBKHJBAAAADPCFNAAAAAABA started|SRC=NSS|UCPU=0|SCPU=0
Output should look like: ... (9 Replies)
Hi,
Need to replace last field in a file(/etc/passwd) ,if first filed matches with particular username.
Scenario:
cat testfor1
deekshi:x:7082:7082::/home/deekshi:/bin/bash
harini1:x:7083:7083::/home/harini1:/bin/bash
Here,if first field contains "deekshi", then i should replace... (4 Replies)
Table
ACN|NAME|CITY|CTY|NO1|NO2
115|AKKK|ASH|IND|10|15
115|AKKK|ASH|IND|20|20
115|AKKK|ASH|IND|30|35
115|AKKK|ASH|IND|30|35
112|ABC|FL|USA|15|15
112|ABC|FL|USA|25|20
112|ABC|FL|USA|25|45
i have written shell script using cut command
and awk programming getting error correct it and add... (5 Replies)
Hi,
I have a date/time field in my file. I have to search in all the records and append a timestamp to it, if the timestamp is missing in that field. Is there a possible awk solution for this?
Field date format
File1
====
1|vamu|payer|2007-12-02 02:01:30|bcbs|... (5 Replies)
Hi,
i want to replace comma by space for specified field in record, i mean i want to replace the commas in the 4th field by space. and rest all is same throught the record.
the record is
16458,99,001,"RIMOUSKI, QC",418,"N",7,EST,EDT,902
16458,99,002,"CHANDLER,... (5 Replies)
Hi,
I am new to unix and am trying to do something below:
I have a pipe delimited file with millions of records. I need to replace the third column of the first record to the number of lines in the file. How can I do that.
Will appreciate any advice and help.
Thanks
Simi (3 Replies)
Hello,
I have the following xml formatted file. I would like to get the newnumber field number and replace into customernumber for each record.
For example:
<XMLFORMAT>
<customernumberR11>9</customernumberR11>
... (12 Replies)