![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Perl: Extracting date from file name and comparing with current date | MKNENI | Shell Programming and Scripting | 4 | 03-26-2008 01:01 PM |
| Processing a log file based on date/time input and the date/time on the log file | primp | Shell Programming and Scripting | 4 | 03-16-2008 08:23 AM |
| Date and time log file | captoro | Shell Programming and Scripting | 8 | 09-03-2007 06:23 PM |
| how do I put a date and time in a file name | jhamm | UNIX for Dummies Questions & Answers | 2 | 01-16-2007 06:31 AM |
| File date and time stamp | Xenon | UNIX for Dummies Questions & Answers | 1 | 10-09-2001 12:58 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Extracting date-time from file.
I have the following file and need to extract date and time part for each record. Pl. could anyone provide an shell script which could be used to do it. Here is the file:
Code:
/rgrdev/pdsud2/unx/agc/src/agcmst:
/rgrsrc/pdspms/unx/agc/src/s.agcmst.for
agcmst.for 420.20 8/4/07 18:30:53
/rgrsrc/pdsbas/unx/agc/src/s.agtrnd.for
agtrnd.for 2.8 8/4/07 18:30:18
/rgrsrc/pdspms/unx/agc/src/s.hyagc.for
hyagc.for 420.2 8/4/07 18:30:36
/rgrsrc/pdspms/unx/agc/src/s.permon.for
permon.for 420.24 8/4/07 18:30:43
/rgrsrc/pdspms/unx/agc/src/s.rescal.for
rescal.for 420.4 8/4/07 18:30:44
/rgrsrc/pdspms/unx/agc/src/s.jouflt.for
jouflt.for 420.6 8/4/07 18:30:38
ercalm.for pdsras 08/04/07 18:30:32
/rgrsrc/pdspms/unx/agc/src/s.rtproc.for
rtproc.for 420.3 8/4/07 18:30:48
timef.c 1.6 12/12/05 16:09:42 /rgrsrc/pdsbas/unx/forshl/src/s.timef.c
rlscrf.c 1.4 12/12/05 16:09:36 /rgrsrc/pdsbas/unx/forshl/src/s.rlscrf.c
GETUCD.c 1.2 5/7/07 16:16:09 /rgrsrc/pdsbas/unx/epashl/src/s.GETUCD.c
/rgrsrc/pdspms/unx/epashl/src/s.llmvar.for
llmvar.for 420.2 5/7/07 16:17:36 @(#) /rgrsrc/pdspms/unx/epashl/src/s.rprcal.for
rprcal.for 420.1 5/7/07 16:18:01 @(#) /rgrsrc/pdspms/unx/epashl/src/s.unmvar.for
unmvar.for 420.3 5/7/07 16:18:22
/rgrsrc/pdspms/unx/epashl/src/s.nsrcal.for
nsrcal.for 420.3 5/7/07 16:17:43 @(#) /rgrsrc/pdspms/unx/epashl/src/s.rrscal.for
rrscal.for 420.5 5/7/07 16:18:01 @(#) /rgrsrc/pdspms/unx/epashl/src/s.dbecal.for
dbecal.for 420.5 5/7/07 16:16:54 @(#) /rgrsrc/pdspms/unx/epashl/src/s.ubecal.for
ubecal.for 420.4 5/7/07 16:18:22 @(#) /rgrsrc/pdspms/unx/epashl/src/s.drscal.for
drscal.for 420.4 5/7/07 16:17:01 @(#) /rgrsrc/pdspms/unx/epashl/src/s.urscal.for
urscal.for 420.4 5/7/07 16:18:23 @(#) /rgrsrc/pdspms/unx/epashl/src/s.loscal.for
loscal.for 420.1 5/7/07 16:17:36
appalm.c 1.5 5/7/07 16:16:14 /rgrsrc/pdsbas/unx/epashl/src/s.appalm.c
topchk.c 1.2 3/11/07 20:45:53 /rgrsrc/pdsbas/unx/scs/src/s.topchk.c
/rgrsrc/pdspms/unx/ed/src/s.findst.for
findst.for 420.1 6/27/07 09:45:34
V1.0
$RCSfile: crt0.s,v $ $Revision: 1.1.26.2 $ (DEC) $Date: 1997/04/03 22:25:40 $
Pl. help me out to find the solution. Early responce highly appreciated. Last edited by vgersh99; 09-04-2007 at 02:09 PM. |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
I saved a few sample entries in the file extract and used awk to extract the relevant entries,
Quote:
Quote:
|
|
#3
|
|||
|
|||
|
digen,
Thanks for the response, but i need to keep the original file as it is by removing the date and time from each record(i donn't care if you remove the latter part after date for each record). I want file like this(Just i have taken few lines from file to explain you): /rgrdev/pdsud2/unx/agc/src/agcmst: /rgrsrc/pdspms/unx/agc/src/s.agcmst.for agcmst.for 420.20 /rgrsrc/pdsbas/unx/agc/src/s.agtrnd.for agtrnd.for 2.8 timef.c 1.6 rlscrf.c 1.4 unmvar.for 420.3 /rgrsrc/pdspms/unx/epashl/src/s.nsrcal.for nsrcal.for 420.3 Hope this will clarify what i am looking for. |
|
#4
|
||||
|
||||
|
Using gnu sed...
Code:
sed -r 's! ..?/..?/.. ..:..:..!!g' file1 > file2 |
|
#5
|
|||
|
|||
|
This sed command is not working. -r option is not valid so i change to -n. When i run this command, it gives message like "sed:Function 's! ..?/..?/.. ..:..:..exitg can not be parsed." when i try to rerun it, it keeps on adding the command and not doing any thing. Pl. could you recheck it.
|
|
#6
|
|||
|
|||
|
Is anyone is having the solution for my problem. Pl. let me know asap. Early response is highly appreciated. I am not very good in Shell prog., so pl. provide the complete code.
|
|
#7
|
||||
|
||||
|
Quote:
|
||||
| Google The UNIX and Linux Forums |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|