Help to switch dates from a file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help to switch dates from a file
# 1  
Old 11-14-2007
Help to switch dates from a file

Hi.
I need some assistance with a file who at the end i must import to EXCEL.

The problem is that i have a file with this inside:

Output:
JOBID START TIME END TIME ELAPSED CPU
------------------------------------------------------------
AVERAGE: no data no data
737516 11-14 01:00 11-14 01:04 00:04:38 00:01:06
827490 11-13 01:00 11-13 01:13 00:13:05 00:02:33
729186 11-12 01:00 11-12 01:00 00:00:40 00:00:32
737438 11-11 01:00 11-11 01:01 00:01:06 00:00:39
770088 11-10 01:00 11-10 01:20 00:20:10 00:02:17


and as you can see, the " 11-10 " is November Ten and so on.
If i import this to Excel , he read's everithing wrong and put's " 11-Out
" . I'm portuguese and it puts 11 of October . It's wrong.

So i was thinking to switch from " MM-DD " to " DD-MM " on Unix and then import to Excel. This must be done on the 2 columns with date.

Can anyone help ?

Regards,
# 2  
Old 11-14-2007
I would have thought that Excel supports a whole range of date formats, I suppose the trick is to tell it which one to use while importing.
# 3  
Old 11-15-2007
is this what you want:
Code:
[yogeshs@PS0814 temp]$ cat job_file
737516 11-14 01:00 11-14 01:04 00:04:38 00:01:06
827490 11-13 01:00 11-13 01:13 00:13:05 00:02:33
729186 11-12 01:00 11-12 01:00 00:00:40 00:00:32
737438 11-11 01:00 11-11 01:01 00:01:06 00:00:39
770088 11-10 01:00 11-10 01:20 00:20:10 00:02:17
[yogeshs@PS0814 temp]$ perl -pi -e 's/(\d{2})-(\d{2})/\2-\1/g' job_file
[yogeshs@PS0814 temp]$
[yogeshs@PS0814 temp]$ cat job_file
737516 14-11 01:00 14-11 01:04 00:04:38 00:01:06
827490 13-11 01:00 13-11 01:13 00:13:05 00:02:33
729186 12-11 01:00 12-11 01:00 00:00:40 00:00:32
737438 11-11 01:00 11-11 01:01 00:01:06 00:00:39
770088 10-11 01:00 10-11 01:20 00:20:10 00:02:17
[yogeshs@PS0814 temp]$

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Grep multiple words in a file with help of fixed string switch

I have multiple strings in a file which have special character $, when i search strings by ignoring $ with \ using single quotes it returns empty results. My search strings are set char_1($lock) and set new_char_clear_3($unlock) I tried searching with but it returns empty results.However... (3 Replies)
Discussion started by: g_eashwar
3 Replies

2. Shell Programming and Scripting

Switch line in txt file

Hi I have problem with replace line in txt file , I have this string: 144185 DISK Piece qqr8ot6l_1_1 -- 144186 DISK Piece ukr8pf2e_1_1 -- 144187 DISK Piece ter8p9gc_1_1 -- 144188 DISK Piece 4er8qb84_1_1 and (8 Replies)
Discussion started by: primo102
8 Replies

3. UNIX for Advanced & Expert Users

How to get the Missing dates between two dates in the table?

Hi Am Using Unix Ksh ... I have a Table called date select * from date ; Date 01/02/2013 06/02/2013 I need the output as Missing Date 01/02/2013 02/02/2013 03/02/2013 04/02/2013 05/02/2013 06/02/2013 (2 Replies)
Discussion started by: Venkatesh1
2 Replies

4. Shell Programming and Scripting

Switch string in the file

Dear all, I have file input like this, file input: input.txt ROUTE 0001, ( 10021)=X 71Y 1605, X 1486Y 2220,X 1720Y 2380,X 1962Y 2553,X 2112Y 2650,X 2289Y 2746, YF 5000, ( 10022)=X 71Y 1605, X 498Y... (4 Replies)
Discussion started by: attila
4 Replies

5. UNIX for Dummies Questions & Answers

How to write the dates between 2 dates into a file

Hi All, I am trying to print the dates that falls between 2 date variables into a file. Here is the example. $BUS_DATE =20120616 $SUB_DATE=20120613 Output to file abc.txt should be : 20120613,20120614,120120615,20120616 Can you pls help me accomplish this in LINUX. Thanks... (5 Replies)
Discussion started by: dsfreddie
5 Replies

6. UNIX for Dummies Questions & Answers

Switch and replace columns in a file

HP-UX I have a fixed length file like this 9921190625797AE2560 20091001US20091001@@NEWSITE @@ 20091013001X X 01NEW00DNA00007081 @@ SPRINGFIELD @@ ... (2 Replies)
Discussion started by: rs1969
2 Replies

7. UNIX for Advanced & Expert Users

vimdiff jump to other file or switch windows

This took me quite awhile to find so I wanted to share this with other people. To switch windows in vimdiff or to navigate windows in vimdiff or to change windows in vimdiff try the following: The ":vertical" command can be inserted before another command that splits a window. ... (0 Replies)
Discussion started by: cokedude
0 Replies

8. Shell Programming and Scripting

what is the switch to let sed edit and save file

I remember there is a sed switch i can use to edit and save the file at the same time, but i cannot recall it at all. so instead of -> sed 's/A/B/' file > file-tmp -> mv file-tmp file what can i do to just let sed edit and save the "file" (4 Replies)
Discussion started by: fedora
4 Replies

9. Shell Programming and Scripting

How to processing the log file within certain dates based on the file name

Hi I am working on the script parsing specific message "TEST" from multiple file. The log file name looks like: N3.2009-11-26-03-05-02.console.log.tar.gz N4.2009-11-29-00-25-03.console.log.tar.gz N6.2009-12-01-10-05-02.console.log.tar.gz I am using the following command: zgrep -a --text... (1 Reply)
Discussion started by: shyork2001
1 Replies

10. Shell Programming and Scripting

Need script to generate all the dates in DDMMYY format between 2 dates

Hello friends, I am looking for a script or method that can display all the dates between any 2 given dates. Input: Date 1 290109 Date 2 010209 Output: 300109 310109 Please help me. Thanks. :):confused: (2 Replies)
Discussion started by: frozensmilz
2 Replies
Login or Register to Ask a Question