Creating a two column list of date pairs form a single column list | Unix Linux Forums | UNIX for Dummies Questions & Answers

  Go Back    


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Creating a two column list of date pairs form a single column list

UNIX for Dummies Questions & Answers


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 08-14-2013
jbrandt1979 jbrandt1979 is offline
Registered User
 
Join Date: Sep 2012
Last Activity: 28 January 2014, 5:02 PM EST
Location: Sacramento, CA
Posts: 6
Thanks: 1
Thanked 0 Times in 0 Posts
Creating a two column list of date pairs form a single column list

Hi all, looking for some help here. I'm what you'd call a dirty programmer. my shell scripts might be ugly, but they (usually) function...

Say I have a single column text file with a list of dates (yyyymmdd) that represent the elevation of a point on that date (I work with land subsidence, so the elevation changes thru time):


Code:
date1
date2
date3
date4
...
date-n

I want to then create another two column text file that contains a list of all possible date combinations, so I can then figure out the change in elevation between two time periods. I need to create this text file for input into another software I use.


Code:
date1  date2
date1  date3
...
date1  date-n
date2  date3
date2  date4
...
date2  date-n
date3  date4
...
date-n-1 date-n

Any ideas?

Thanks all!
JB

Last edited by Scott; 08-14-2013 at 03:16 PM.. Reason: Code tags
Sponsored Links
    #2  
Old 08-14-2013
RudiC RudiC is offline Forum Advisor  
Registered User
 
Join Date: Jul 2012
Last Activity: 22 September 2014, 4:24 PM EDT
Location: Aachen, Germany
Posts: 4,273
Thanks: 72
Thanked 1,031 Times in 977 Posts
Try (for seven dates):

Code:
awk '{T[NR]=$1} END {for (i=1; i<NR; i++) {for (j=i+1; j<=NR; j++) print T[i], T[j]}}' file
date1 date2
date1 date3
date1 date4
date1 date5
date1 date6
date1 date7
date2 date3
date2 date4
date2 date5
date2 date6
date2 date7
date3 date4
date3 date5
date3 date6
date3 date7
date4 date5
date4 date6
date4 date7
date5 date6
date5 date7
date6 date7

Sponsored Links
    #3  
Old 08-15-2013
jbrandt1979 jbrandt1979 is offline
Registered User
 
Join Date: Sep 2012
Last Activity: 28 January 2014, 5:02 PM EST
Location: Sacramento, CA
Posts: 6
Thanks: 1
Thanked 0 Times in 0 Posts
perfect, thanks!!!!
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
List several files into one single column lucasvs UNIX for Dummies Questions & Answers 2 02-16-2012 09:14 PM
Creating a column based list from a string list kristinu UNIX for Dummies Questions & Answers 3 01-12-2012 02:07 PM
Construct 3 column table from one column list martindebruin Shell Programming and Scripting 11 08-05-2011 10:51 AM
need to get single column form csv file ponmuthu UNIX for Advanced & Expert Users 7 07-28-2010 09:22 AM
Sorting list of files per date column shivaastrogun UNIX for Dummies Questions & Answers 10 11-06-2008 07:47 PM



All times are GMT -4. The time now is 08:25 PM.