08-27-2009
Extracting Date from string
Hi Gurus
I want to extract a date and version code which shall come in filename consisting of underscores.
The filename can contain any / one underscores but the version number will come after date and will be separted by underscore
String formats
=============
ABC_20090815_2.csv
ABC_DEF_20090815_2.csv
ABC_DEF_GH_20090815_2.csv
ABC_DEF_G_I_20090815_2.csv
ABC_DEF_M_N_O_P_20090815_2.csv
In each case i want to extract
date -- 20090815 and
version number -- 2
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi All.,
1 ssssss C2052EX 15 Mar 30 19:01
1 aaaaa C2052EX 15 Apr 3 10:12
1 ccccc C2052EX 15 Apr 4 09:28
i have files arriving like above.
i am using the following to extract files arriving today ( say apr4)
todaydat=`date | cut -c5-10`
find... (1 Reply)
Discussion started by: pavan_test
1 Replies
2. Shell Programming and Scripting
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:
/rgrdev/pdsud2/unx/agc/src/agcmst:
/rgrsrc/pdspms/unx/agc/src/s.agcmst.for
agcmst.for 420.20 8/4/07 18:30:53
... (7 Replies)
Discussion started by: skumar11
7 Replies
3. Shell Programming and Scripting
Hi,
Need to extract a string from one file and search the same in other files.
Ex:
I have file1 of hundred lines with no delimiters not even space.
I have 3 more files.
I should get 1 to 10 characters say substring from each line of file1 and search that string in rest of the files and get... (1 Reply)
Discussion started by: mohancrr
1 Replies
4. Shell Programming and Scripting
I need to extract the date part from the file name (20080221 in this ex) and compare it with the current date and delete it, if it is a past date.
$file = exp_ABCD4_T-2584780_upto_20080221.dmp.Z
really appreciate any help.
thanks
mkneni (4 Replies)
Discussion started by: MKNENI
4 Replies
5. UNIX for Dummies Questions & Answers
HIya,
Having a dumb day whilst writing an archive process in Shell want to extract from the filename the date and archive into tar files based on this, I don't want to use mtime as it may not be the actual file date.
The files are
-rw-rw---- 1 user admin 100 Aug 29 11:10... (2 Replies)
Discussion started by: badg3r
2 Replies
6. UNIX for Dummies Questions & Answers
Hi,
I am a beginner in Unix so please bear with me...
I have a directory which has files in format: RECF-YYYY-MM-DD-input. For example, RECF-2008-02-25-input. I need to extract the YYYYY-MM-DD substring from this filename and convert that into date and compare it with a date. How do I do that?... (7 Replies)
Discussion started by: laiko
7 Replies
7. Homework & Coursework Questions
1. The problem statement, all variables and given/known data:
I have standard web server log file. It contains different columns (like IP address, request result code, request type etc) including a date column with the format .
I have developed a log analysis command line utility that displays... (1 Reply)
Discussion started by: TariqYousaf
1 Replies
8. Shell Programming and Scripting
Hi again:
I have this file:
"2010-11-1 11:50:00",40894,13.38,17.24,12.92,13.23,"2010-11-14
11:43:02",12.56,"2010-11-14 11:46:02",22.68,20.95,"2010-11-14
11:44:03",2.144,2.078,190.4,14.27,6.293,"2010-11-14 ... (2 Replies)
Discussion started by: iga3725
2 Replies
9. Homework & Coursework Questions
You are given a 1 year logfile with each line starting with a date in the form “YYYY-MM-DD”. How would you extract logs from the 4th day of each month and put them into a new file (1 Reply)
Discussion started by: DOkuwa
1 Replies
10. Shell Programming and Scripting
Hello.
First best wishes for everybody.
here is the input file ("$INPUT1") contents :
BASH_FUNC_message_begin_script%%=() { local -a L_ARRAY;
BASH_FUNC_message_debug%%=() { local -a L_ARRAY;
BASH_FUNC_message_end_script%%=() { local -a L_ARRAY;
BASH_FUNC_message_error%%=() { local... (3 Replies)
Discussion started by: jcdole
3 Replies
LEARN ABOUT DEBIAN
ost_date
ost::Date(3) Library Functions Manual ost::Date(3)
NAME
ost::Date -
The Date class uses a julian date representation of the current year, month, and day.
SYNOPSIS
#include <numbers.h>
Inherited by ost::DateNumber, and ost::Datetime.
Public Member Functions
Date (time_t tm)
Date (tm *dt)
Date (char *str, size_t size=0)
Date (int year, unsigned month, unsigned day)
Date ()
virtual ~Date ()
int getYear (void) const
unsigned getMonth (void) const
unsigned getDay (void) const
unsigned getDayOfWeek (void) const
char * getDate (char *buffer) const
time_t getDate (void) const
time_t getDate (tm *buf) const
long getValue (void) const
void setDate (const char *str, size_t size=0)
bool isValid (void) const
operator long () const
String operator() () const
Date & operator++ ()
Date & operator-- ()
Date & operator+= (const long val)
Date & operator-= (const long val)
int operator== (const Date &date)
int operator!= (const Date &date)
int operator< (const Date &date)
int operator<= (const Date &date)
int operator> (const Date &date)
int operator>= (const Date &date)
bool operator! () const
Protected Member Functions
void toJulian (long year, long month, long day)
void fromJulian (char *buf) const
virtual void update (void)
A method to use to 'post' any changed values when shadowing a mixed object class.
Protected Attributes
long julian
Friends
Date operator+ (const Date &date, const long val)
Date operator- (const Date &date, const long val)
Date operator+ (const long val, const Date &date)
Date operator- (const long val, const Date &date)
Detailed Description
The Date class uses a julian date representation of the current year, month, and day.
This is then manipulated in several forms and may be exported as needed.
Author:
David Sugar dyfet@ostel.com julian number based date class.
Constructor & Destructor Documentation
ost::Date::Date (time_ttm)
ost::Date::Date (tm *dt)
ost::Date::Date (char *str, size_tsize = 0)
ost::Date::Date (intyear, unsignedmonth, unsignedday)
ost::Date::Date ()
virtual ost::Date::~Date () [virtual]
Member Function Documentation
void ost::Date::fromJulian (char *buf) const [protected]
char* ost::Date::getDate (char *buffer) const
time_t ost::Date::getDate (void) const
time_t ost::Date::getDate (tm *buf) const
unsigned ost::Date::getDay (void) const
unsigned ost::Date::getDayOfWeek (void) const
unsigned ost::Date::getMonth (void) const
long ost::Date::getValue (void) const
int ost::Date::getYear (void) const
bool ost::Date::isValid (void) const
Reimplemented in ost::Datetime.
ost::Date::operator long () const [inline]
bool ost::Date::operator! (void) const [inline]
Reimplemented in ost::Datetime.
int ost::Date::operator!= (const Date &date)
String ost::Date::operator() () const
Date& ost::Date::operator++ ()
Date& ost::Date::operator+= (const longval)
Date& ost::Date::operator-- ()
Date& ost::Date::operator-= (const longval)
int ost::Date::operator< (const Date &date)
int ost::Date::operator<= (const Date &date)
int ost::Date::operator== (const Date &date)
int ost::Date::operator> (const Date &date)
int ost::Date::operator>= (const Date &date)
void ost::Date::setDate (const char *str, size_tsize = 0)
void ost::Date::toJulian (longyear, longmonth, longday) [protected]
virtual void ost::Date::update (void) [protected], [virtual]
A method to use to 'post' any changed values when shadowing a mixed object class. This is used by DateNumber.
Reimplemented in ost::DateNumber.
Friends And Related Function Documentation
Date operator+ (const Date &date, const longval) [friend]
Date operator+ (const longval, const Date &date) [friend]
Date operator- (const Date &date, const longval) [friend]
Date operator- (const longval, const Date &date) [friend]
Member Data Documentation
long ost::Date::julian [protected]
Author
Generated automatically by Doxygen for GNU CommonC++ from the source code.
GNU CommonC++ Sat Jun 23 2012 ost::Date(3)