awk - Multiple files - 1 file with multi-line data
Greetings experts,
Have 2 input files, of which 1 file has 1 record per line; in 2nd file, multiple lines constitute 1 record; Hence declared the RS=";"
Now in the first file which ends with ";" at each line of the line; But \nis also being considered as part of the data due to which
I am facing some issues; How to avoid this.
File1: FS=@ RS=; (forced to use RS=; as for the file2 it spans across multiple lines)
File2:
awk_code:
Output:
As you can see that after this line src and tgt tables the data jumped into the other line from which I assume
that there is embedded \n which is not present in join_array I guess (present without embedded newline char)
Expected Output: -- For readability I have split the data into multiple rows
As RS=";" the data in the array for the first record in file1 is as expected; But for the next records, there is \n embedded
into the array before next records first column is read as you can see from the above
hence not printing the data relative to this in join_array;
How to overcome this please..
Edit:
Please excuse any syntax issues as I am not able to copy/paste;
I'm sorry, but we can't ignore syntax issues. If you can't accurately show us what your code really looks like, we can waste our time and yours pointing out reasons why you code won't work when it has nothing to do with your problem. Our crystal balls don't work well enough to read code that you haven't shown us.
I haven't tried to work out the logic of what your awk code is doing, but there are two obvious problems with what you have shown us:
First, just like the BEGIN keyword is all uppercase, the end in your code needs to be END.
And, second, the awk utility reads from standard input when no file operands are specified on the command line and when - is specified as a file operand. So try changing the last line of your script from:
to:
so awk will see two file operands instead of being given your first file on standard input and you second file as the only file operand.
If these changes don't fix your problem, please show us what happens after making these changes and we'll help you debug it further. And, please find a way to show us your actual code (either copy & paste or upload).
And, DO NOT show us expected output that is not your expected output. If we can't tell what was done to make it readable instead of being the actual output you expect, you are just adding confusion to your specification.
We have the data looks like below in a log file.
I want to generat files based on the string between two hash(#) symbol like below
Source:
#ext1#test1.tale2 drop
#ext1#test11.tale21 drop
#ext1#test123.tale21 drop
#ext2#test1.tale21 drop
#ext2#test12.tale21 drop
#ext3#test11.tale21 drop... (5 Replies)
Greetings Experts,
As part of automating the sql generation, I have the source table name, target table name, join condition stored in a file join_conditions.txt which is a delimited file (I can edit the file if for any reason). The reason I needed to store is I have built SELECT list without... (5 Replies)
Greetings Experts,
I need to handle the views created over monthly retention tables
for which every new table in YYYYMMDD format, there is
equivalent view created and the older table which might be
dropped, the view over it has to be re-created over a dummy
table so that it doesn't fail.... (2 Replies)
Hi Experts,
I have a data with multiple entry , I want to filter PKG= & the last column "00060110" or "00088150" in the output
file:
###############################################################################################
PKG= P8SDB :: VGS = vgP8SOra vgP8SDB1 vgP8S001... (5 Replies)
Hi,
I have a problem where I need to make this input:
nameRow1a,text1a,text2a,floatValue1a,FloatValue2a,...,floatValue140a
nameRow1b,text1b,text2b,floatValue1b,FloatValue2b,...,floatValue140b
look like this output:
nameRow1a,text1b,text2a,(floatValue1a - floatValue1b),(floatValue2a -... (4 Replies)
I have a file with data records separated by multiple equals signs, as below.
==========
RECORD 1
==========
RECORD 2
DATA LINE
==========
RECORD 3
==========
RECORD 4
DATA LINE
==========
RECORD 5
DATA LINE
==========
I need to filter out all data from this file where the... (2 Replies)
Hi,
I have a directory full of *.txt files. I would like to print the last line of every file to screen.
I know you can use FNR for printing the first line of each file, but how do I access the last line of each file?
This code doesn't work, it only prints the last line of the last file:BEGIN... (5 Replies)
Hi,
I'd like to process multiple files. For example:
file1.txt
file2.txt
file3.txt
Each file contains several lines of data. I want to extract a piece of data and output it to a new file.
file1.txt ----> newfile1.txt
file2.txt ----> newfile2.txt
file3.txt ----> newfile3.txt
Here is... (3 Replies)
Hi,
I'm using AWK to try to extract data from multiple files (*.txt). The script should look for a flag that occurs at a specific position in each file and it should return the data to the right of that flag.
I should end up with one line for each file, each containing 3 columns:... (8 Replies)
I have a 500 MB XML file from a FileMaker database export, it's formatted horribly (no line breaks at all). The node structure is basically
<FMPXMLRESULT>
<METADATA>
<FIELD att="............." id="..."/>
</METADATA>
<RESULTSET FOUND="1763457">
<ROW att="....." etc="....">
... (16 Replies)