sort calendar files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting sort calendar files
# 1  
Old 01-26-2012
sort calendar files

I have a few .calendar files
/usr/share/calendar
they look like

Code:
01/01<TAB>Anniversary of the Triumph of the Revolution in Cuba
01/24<TAB>Gold discovered in California at Sutter's Mill, 1848
01/28<TAB>First ski tow, Woodstock VT, 1914
01/28<TAB>Space Shuttle Challenger (51-L) explodes 74 seconds after liftoff
<TAB>killing Scobee, Smith, McNair, Resnick, Jarvis, Onizuka and McAuliffe,
<TAB>1986

but for better reading, they should look like

Code:
01/24<TAB>1848 Gold discovered in California at Sutter's Mill
01/28<TAB>1914 First ski tow, Woodstock VT
01/28<TAB>1986 Space Shuttle Challenger (51-L) explodes 74 seconds after liftoff
<TAB>killing Scobee, Smith, McNair, Resnick, Jarvis, Onizuka and McAuliffe

At the moment, don't know how to start, any hints.

Thanks in advance
rain

Last edited by methyl; 01-26-2012 at 06:17 PM.. Reason: please use code tags
# 2  
Old 01-26-2012
Code:
$
$ cat f51
01/01   Anniversary of the Triumph of the Revolution in Cuba
01/24   Gold discovered in California at Sutter's Mill, 1848
01/28   First ski tow, Woodstock VT, 1914
01/28   Space Shuttle Challenger (51-L) explodes 74 seconds after liftoff
        killing Scobee, Smith, McNair, Resnick, Jarvis, Onizuka and McAuliffe,
        1986
$
$
$ perl -lne 'BEGIN {undef $/} while (/(\d\d\/\d\d)\t([^\/]*?),[ \n]*[\t]*(\d{4})$/msg) {print "$1\t$3 $2"}' f51
01/24   1848 Gold discovered in California at Sutter's Mill
01/28   1914 First ski tow, Woodstock VT
01/28   1986 Space Shuttle Challenger (51-L) explodes 74 seconds after liftoff
        killing Scobee, Smith, McNair, Resnick, Jarvis, Onizuka and McAuliffe
$
$

tyler_durden
# 3  
Old 01-26-2012
Thank you for your help,
works perfect.
rain
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to sort these files?

Hi, An ls outputs this -rw-rw-rw- 1 jeisma users 0 Aug 8 09:24 file.d1 -rw-rw-rw- 1 jeisma users 0 Aug 8 09:24 file.d10 -rw-rw-rw- 1 jeisma users 0 Aug 8 09:24 file.d11 -rw-rw-rw- 1 jeisma users 0 Aug 8 09:25 file.d2... (3 Replies)
Discussion started by: jeisma
3 Replies

2. Shell Programming and Scripting

How to sort the files according to the number?

Hi Everyone, I have a question: I have a lot of file named like or10000.dat, or9100.dat, or100.dat, or3100.dat... I want to deal with these files according to the number in the name. So I want to deal with or100.dat first and then or3100.dat and so on. I used : for i in `ls or*.dat |... (11 Replies)
Discussion started by: wxuyec
11 Replies

3. Shell Programming and Scripting

sort the files based on timestamp and execute sorted files in order

Hi I have a requirement like below I need to sort the files based on the timestamp in the file name and run them in sorted order and then archive all the files which are one day old to temp directory My files looks like this PGABOLTXML1D_201108121235.xml... (1 Reply)
Discussion started by: saidutta123
1 Replies

4. Shell Programming and Scripting

Sort and output to different files

Hi all! I have a comma delimited file and I'm sorting it based on fields 6, 8 and 10. The following does the job: sort -t, -nk6,10 unsorted.txt -o sorted.txt What I need to do now is to write every row containing same values on fields 6, 8 and 10 to a different file. Any ideas on how to do... (2 Replies)
Discussion started by: Tr0cken
2 Replies

5. UNIX for Advanced & Expert Users

Script to sort the files and append the extension .sort to the sorted version of the file

Hello all - I am to this forum and fairly new in learning unix and finding some difficulty in preparing a small shell script. I am trying to make script to sort all the files given by user as input (either the exact full name of the file or say the files matching the criteria like all files... (3 Replies)
Discussion started by: pankaj80
3 Replies

6. UNIX for Dummies Questions & Answers

Sort two files by time

I had a question about sorting two files which contain data like the following: File 1: 09:12:12 blah blah 0 blah blah 1 blah blah 2 blah blah 09:12:15 blah blah 0 blah blah 1 blah blah 2 blah blah File 2: 09:12:13 blah2 0 blah2 1 blah2 2 ... (1 Reply)
Discussion started by: rowd23
1 Replies

7. UNIX for Dummies Questions & Answers

sort and compare files

Hi, I have around 14-15 files and i want to sort all the files and then compare. I dont want to sort them and store in a different file and then compare. I want to compare two files at a time. Is there a way we can do this using a single command? (5 Replies)
Discussion started by: dnat
5 Replies

8. Shell Programming and Scripting

sort files

i have a folder contails 3 types of files , ls -l -rw-r--r-- 1 oratest dba 7 Jul 1 15:36 aml001.agl -rw-r--r-- 1 oratest dba 7 Jul 1 15:36 aml002.agl -rw-r--r-- 1 oratest dba 6 Jul 1 15:43 aml003.agl -rw-r--r-- 1 oratest dba 7 Jul 1 15:36 bom001.agl -rw-r--r-- 1 oratest dba 7... (4 Replies)
Discussion started by: Elii
4 Replies

9. UNIX for Dummies Questions & Answers

Sort files by date, not showing files from today

Hi all, i'm new here in this forum. I really like the helpful answers in this forum. Here a short question. For a script i have to sort files by date and exclude the files of the actual date. Sorting the files by date and preparing the output for awk is done by this line: ls -l... (3 Replies)
Discussion started by: carlosdivega
3 Replies

10. UNIX for Dummies Questions & Answers

sort files

Hi Can some one help me with sorting a file where i am supposed to sort based on the last column(i.e 3rd column) and then by 1 st column Sample data 2 ishika 4 5 suj 3 10 raj 4 23 fff 3 45 amar 4 to be sorted to 5 suj 3 23 fff 3 2 ishika 4 10 raj 4 45 amar 4 I tried to sort... (2 Replies)
Discussion started by: mita10
2 Replies
Login or Register to Ask a Question