LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 05-09-2013, 01:39 AM   #1
budgie26
LQ Newbie
 
Registered: Nov 2012
Posts: 17

Rep: Reputation: Disabled
Create a list of date pairings based on a list of dates


I have a file with dates which I need to use to make a new list of all possible date pairings, where the 1st date is older than the 2nd date. For example:

dates.txt contains a set of dates:

16022007
05082007
25122007
11032008
27072008

I want an output that looks like:

16022007 05082007
16022007 25122007
16022007 11032008
16022007 27072008
05082007 25122007
05082007 11032008
05082007 27072008
25122007 11032008
25122007 27072008
11032008 27072008

This starts by putting 1st date into column 1 and then appending the 2nd row onwards dates to the 1st date in column 2. This continues until the 2nd last row is appended to the last row.

Does anyone know if it's possible to create a script that does this? I have several date files I need to do this to, so having a script that calculates this automatically would be great.

I've played around with loops and awk, but don't have enough scripting experience to work this out.
 
Old 05-09-2013, 02:10 AM   #2
GlennsPref
Senior Member
 
Registered: Apr 2004
Location: Brisbane, Australia
Distribution: Devuan
Posts: 3,411
Blog Entries: 33

Rep: Reputation: 222Reputation: 222Reputation: 222
Hi, I think you are about to get a bunch of shell scripts to do this for you, (duck!)

but while the work gets done,

you might want to check out these ibm tutes, for example and some others.

grep, sed, awk and vi.

I have managed to use a few simple commands in a text file/shell script that have saved me hours of manual editing.

Like working out my bandwidth usage from a .cvs file supplied by the isp.

Hope this helps, Glenn
 
Old 05-09-2013, 02:40 AM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.10, Centos 7.5
Posts: 17,670

Rep: Reputation: 2487Reputation: 2487Reputation: 2487Reputation: 2487Reputation: 2487Reputation: 2487Reputation: 2487Reputation: 2487Reputation: 2487Reputation: 2487Reputation: 2487
Read these
http://rute.2038bug.com/index.html.gz
http://tldp.org/LDP/Bash-Beginners-G...tml/index.html
http://www.tldp.org/LDP/abs/html/

then show us your best effort. We prefer to help, rather than just hand out ready-made solns.
http://www.linuxquestions.org/linux/rules.html
 
  


Reply


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] I need help with a script to list deleted files with dates JangoFett353 Linux - Newbie 13 03-31-2011 11:19 AM
'E:Malformed line 54 in source list /etc/apt/sources.list (dist parse), E:The list of vsssuccess@gmail.com Linux - Desktop 1 11-17-2010 08:17 AM
[SOLVED] Use date with touch to create new file with date based name craigjl Linux - Newbie 5 03-12-2010 09:46 AM
List packages WITH install date? ranger_nemo Ubuntu 4 02-21-2008 05:51 PM
List/compare a directory's files' creation and modification dates LittleTrish Linux - Newbie 3 10-22-2007 02:38 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:01 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