Quote:
|
Originally Posted by aigles
A possible solution :
Code:
awk 'NR==FNR { keys[$1]++ ; next } $1 in keys' file2 file1
Jean-Pierre.
|
It works on the above question. however, my real problem is more complicated: the file1 is actually an XML file like this:
...
<object
type="user"
id="000039BF228B"
encryptedPassword=""
maxConnections=""
>
<checkListAttributes>
</checkListAttributes>
</object>
...
<object
type="user"
id="0000E2801BFD"
encryptedPassword=""
>
<checkListAttributes>
</checkListAttributes>
</object>
...
and file2 is a list of id, as:
...
000039BF228B
0000E2801BFD
...
I want to delete all the blocks whose id is not in file2, and keep those with id in file2. I think we can change the RS (record separator to </object>), but I do not know how to do the whole job. would you help again?