checking if table name is repeated in file and if yes ,remove it
Hi All
I have an output file that looks like this: Quote:
status for ACCOUNT_MISSING_FRM_RCIS_LINK- mismatch status for ACCOUNT_MISSING_FRM_RCIS_LINK is ACCOUNT_MISSING_FRM_RCIS_LINK- does not exist in DB this should appear just once as : Quote:
for further information the ACCOUNT_MISSING_FRM_RCIS_LINK is a table name and it row count is taken from a log and then Database checked for the rowcount to see if it is a match,mismatch,or the table does not exist!! I am getting the desird output just that i need to do something to this output file. Any help will be greatly appricited.Thankyou!!!! |
Hi,
This could work, depending on the rest of the file: Code:
sed 's/status for .* is /status for /' infile |
Hi druuna
i tried ur sed but it is doing only part of the job.i am posting the output. Quote:
status for TABLE_X_UDP_LVL2_VW_BASE_TMP- does not exist in DB status for TABLE_X_UDP_LVL4_VW_BASE_TMP- does not exist in DB status for TABLE_X_UDP_LVL5_VW_BASE_TMP- does not exist in DB which meand that the first line in case where the table name is same should be deleted. thankyou so much.I really really appreciate!!! |
Quote:
|
hi TBone
the input file to this script is: Quote:
Quote:
Quote:
status for TABLE_X_UDP_LVL2_VW_BASE_TMP- does not exist in DB[/B] status for TABLE_X_UDP_LVL3_VW_BASE_TMP- mismatch status for TABLE_X_UDP_LVL4_VW_BASE_TMP- does not exist in DB status for TABLE_X_UDP_LVL5_VW_BASE_TMP- does not exist in DB status for TEMP_ADDRESS_WO_ACC- does not exist in DB[/QUOTE] ANY HELP WOULD BE GREATLY APPRECIATED!!!! |
Hi,
Would it be an idea to remove all the status for XYZ - does not exist in DB lines (trying to keep it simple)? Or are there lines like that that do _not_ have a previous line with the same table name? This should work, assuming that the duplicate tables are right after eachother: Code:
#!/bin/bash Hope this helps. |
Quote:
ABC match it means that thae rowcount for table ABC is same in log file as well as in database ABC mismatch means that the rowcount for ABC is different in database ABC does not exist means that the table ABC does not exist in databse.So there is a difference in MISMATCH and DOES NOT EXIST which is why we cannot remove all the status for XYZ - does not exist in DB lines . Quote:
status for table ABC mismatch status for table ABC does not exist in database so i just want to get rid of status for table ABC mismatch what i was thinking is to write a sed liner which finds the pattern does not exist in database and deletes the line above.I think this should work and I tried awk -v RS='[^\n]*\n*pattern\n[^\n]*' '{print}' ORS="" infile but it is not wkng.please help. |
Hi,
Ignore, see my next post. My previous answer had 2 parts, the second (the awk shell script) should do what you want. It is not related to the previous paragraph. I'm talking about this part: Code:
#!/bin/bash EDIT: Hold on..... I seem to have made misread something. Be right back ;) |
Hi,
Please don't mix your wanted output..... From post #1 Quote:
Quote:
Code:
#!/bin/bash Code:
#!/bin/bash |
it doesnt work!!!
|
"It" does work on my side.........
|
Maybe something like:
Code:
awk -F"[ -]+" 'NR == 1{x = $0;y = $3;next}{if(y != $3){print x;x = $0;y = $3}else{$3=$4="";x = $0}}' file |
Thankyoy all for helping me solve this one...hats off to this forum!!!!!!!!
|
Don't forget to thank members for their useful reply.
|
All times are GMT -5. The time now is 12:32 PM. |