LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-27-2014, 11:27 AM   #1
conejo_perez16
LQ Newbie
 
Registered: Aug 2012
Posts: 10

Rep: Reputation: Disabled
Question 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
 
Old 01-27-2014, 03:55 PM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 6,577
Blog Entries: 14

Rep: Reputation: 969Reputation: 969Reputation: 969Reputation: 969Reputation: 969Reputation: 969Reputation: 969Reputation: 969
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.
 
Old 01-27-2014, 03:57 PM   #3
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 17,919

Rep: Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689Reputation: 3689
Quote:
Originally Posted by conejo_perez16 View Post
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.
 
  


Reply

Tags
condition, find, loop, matching, search


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] bash suggestions to convert horizontal columns to vertical columns Guyverix Programming 14 01-24-2013 12:03 PM
SQL statements howto -- 3 columns input but 2 columns output fhleung Programming 3 11-29-2012 11:45 AM
awk - rearrange column data in csv file to match columns wolverene13 Programming 9 12-21-2011 05:55 AM
[SOLVED] AWK: add columns while keep format for other columns cristalp Programming 3 10-13-2011 07:14 AM
[SOLVED] Match codes in first column in 2 files and return data in other columns cgcamal Programming 12 09-30-2011 02:03 AM


All times are GMT -5. The time now is 02:19 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration