Sure thing.
Here's my idea with awk:
1. read your ComparisonFile into an array indexed by $0 (hint: FNR==NR)
2. for each odd line in MainFile, substituting first , by itself appended with the last field on a line followed by : . Set a flag
3. If flag is set and you're on an even line, output the line and reset the flag.
Regarding your remark 1, I did not understand what happens when we read the ComparisonFile into array but here you are:
Do not understand how to use ReadArray file in this case.
Now, read the last column in Mainfile and if it's the same with $1 (line in ComparisonFile), replace , by ,$1::
This is what I learnt so far.
PS: As I could not append even/oddfunction into it, I do not know how flag will understand when it will be turned on/off.
Many thanks
Boris
Last edited by baris35; 10-02-2018 at 05:55 PM..
Reason: even/odd missed
Hi,
I would like to cut a specific line from a text file and then manipulate the text in that line.
For eg. below is "tmp" file.
-----------------
Tue 07/05/05 00:27:34.333
Tue 07/05/05 00:27:34.333 4 events were processed for customer 315 and will be correctly resolved when 315MERGE is run:... (2 Replies)
How to manipulate first column and reverse the line order in third and fourth column as follws?
For example i have a original file like this:
file1
0.00000000E+000 -1.17555359E-001 0.00000000E+000
2.00000000E-002 -1.17555359E-001 0.00000000E+000
... (1 Reply)
How can I print a section of each line in a text file. Eg
CODE1 XYR Test2 10319389
CODE2 XYR Test2 10319389
CODE3 XYR Test2 10319389
CODE4 XYR Test2 10319389
CODE5 XYR Test2 10319389
First thing that would be nice would a new file like, awk sed and substring may help but can't figure it... (6 Replies)
I am writing a shell script for some purpose. I have a variable of the form -- var1 = "policy=set policy"
Now I need to manipulate the variable var to get the string after index =. that is i should have "set polcy". Also I need to to this for many other variables where the value of "=" is not... (3 Replies)
I get a file which has all its content in a single row.
The file contains xml data containing 3000 records, but all in a single row, making it difficult for Unix to Process the file.
I decided to insert a new line character at all occurrences of a particular string in this file (say replacing... (4 Replies)
I am having a text file which is having more than 200 lines.
EX:
001010122 12000 BIB 12000 11200 1200003
001010122 2000 AND 12000 11200 1200003
001010122 12000 KVB 12000 11200 1200003
In the above file i want to search for string KVB and add/replace... (1 Reply)
Hi,
I have a file which is an extract of jil codes of all autosys jobs in our server.
Sample jil code:
**************************
permission:gx,wx
date_conditions:yes
days_of_week:all
start_times:"05:00"
condition: notrunning(appDev#box#ProductLoad)... (1 Reply)