LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   If (match) between 2 columns do nothing, else copy missing value (https://www.linuxquestions.org/questions/linux-newbie-8/if-match-between-2-columns-do-nothing-else-copy-missing-value-4175492753/)

conejo_perez16 01-27-2014 10:27 AM

If (match) between 2 columns do nothing, else copy missing value
 
Hello everyone I have many text files I need to analyze.

They consist of 2 columns of numbers like the following:

file_1.txt

375012020 375012020
375012021
375012022 375012022
375022022

Please note:

- The 1st and 3rd row are completely equal
- In the second row there is a missing value
- This value is listed in the second column of the last row but with the 3rd character switched (2 instead of 1)

If this were the case then I need to copy this value (375022022) to another text file

Hope someone could pleas help me

MensaWater 01-27-2014 02:55 PM

Uh...

3rd character?

The second row has:
123456789 Count
375012021 Value

The last row has:
123456789 Count
375022022 Value

So I see difference in 5th and 9th characters but none in 3rd. Please explain what you meant by 3rd.

Also everything is left justified so it appears that the value in the last row is the first field and not the second as you indicated. What would put the second field of the second row AFTER the third row?

Also are all of your text files ONLY 4 lines long like this or is this just a subset? If NOT then you shouldn't say "last line" as any answer you get would be wrong.

TB0ne 01-27-2014 02:57 PM

Quote:

Originally Posted by conejo_perez16 (Post 5106161)
Hello everyone I have many text files I need to analyze. They consist of 2 columns of numbers like the following:

file_1.txt
375012020 375012020
375012021
375012022 375012022
375022022

Please note:

- The 1st and 3rd row are completely equal
- In the second row there is a missing value
- This value is listed in the second column of the last row but with the 3rd character switched (2 instead of 1)

If this were the case then I need to copy this value (375022022) to another text file Hope someone could pleas help me

Sure, we'll be glad to help you...so why don't you post what you've written/tried on your own, and tell us where you're stuck?? But we aren't going to write your scripts for you.


All times are GMT -5. The time now is 12:49 PM.