Sponsored Content
Top Forums Shell Programming and Scripting Date format check and replace string in PERL Post 302570960 by ahamed101 on Saturday 5th of November 2011 03:00:11 AM
Old 11-05-2011
Oops didn't see that... Try this...
Code:
#!/usr/bin/perl
my $Y1 = 2011;
my $Y2 = 11;
my $m1 = 11; #---- current month november
my $d1 = 05; #---- current day
my $dateformat = 'yyyymmdd';
$_=$dateformat;
s/yyyy/$Y1/g; s/yy/$Y2/g; s/mm/$m1/; s/dd/$d1/;               
my $dateval=$_;
print $dateval;

--ahamed

Last edited by ahamed101; 11-05-2011 at 04:06 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Check the format of Date

Hi, I have a date field in my input file. I just want to check if its in the format "DD-MM-YYYY". Is there any command which can achieve this? Thanks and Regards, Abhishek (2 Replies)
Discussion started by: AAA
2 Replies

2. Shell Programming and Scripting

How to search a date format from a file an replace with a string in PERL

I am very new to Perl. I am struggling so hard to search a date (such as 10/09/2009, 10-09-2009) from a text file and replace with a string (say DATE) using Perl. Please help me out. Thanks in advance. Regds Doren (4 Replies)
Discussion started by: my_Perl
4 Replies

3. Shell Programming and Scripting

Check input date format?

how to check input date format. for example $input_date must be in format dd.mm.gg script is execute like this: bin/script1.sh 14.12.2009 script1.sh code: #!/bin/sh input_date=$1 CMD="/app/si/test/test.sh $input_date" echo "*****" $CMD (2 Replies)
Discussion started by: waso
2 Replies

4. Shell Programming and Scripting

PERL String to Date (Custom format yyyymmdd to dd-mon-yyyy)

Hi All, I am learning PERL for one of the projects, and in one of these scripts, I read a flat text file and print in the terminal. The problem is, the text file has a date field. The format is yyyymmdd. I need to display this as dd-mon-yyyy. Any ideas to do this? Thanks a lot for the... (9 Replies)
Discussion started by: guruparan18
9 Replies

5. Shell Programming and Scripting

Need to check date format yyyymm

My source file having one date column. The formate of the date column is yyyymm. I need to validate whether all the rows are in same format in the given file. If it is not I have captured that records in a separate file. I am very new to Unix. I don't how to achieve this. Plz help me to achieve... (2 Replies)
Discussion started by: suresh01_apk
2 Replies

6. Shell Programming and Scripting

PERL : hhmiss - Date format check and replace

I have a filename, This can be any of any format, I want to check if the filename has hours,mins and seconds part. If it is present, i want to replace it with a " * " (star symbol) output needed: IMP: The time part can be in any pattern. How can this be done?:confused:... (3 Replies)
Discussion started by: irudayaraj
3 Replies

7. Shell Programming and Scripting

finding date numeral from file and check the validity of date format

hi there I have file names in different format as below triss_20111117_fxcb.csv triss_fxcb_20111117.csv xpnl_hypo_reu_miplvdone_11172011.csv xpnl_hypo_reu_miplvdone_11-17-2011.csv xpnl_hypo_reu_miplvdone_20111117.csv xpnl_hypo_reu_miplvdone_20111117xfb.csv... (10 Replies)
Discussion started by: manas_ranjan
10 Replies

8. Shell Programming and Scripting

Perl code to check date and check files in particular dir

Hi Experts, I am checking how to get day in Perl. If it is “Monday” I need to process…below is the pseudo code. Can you please prove the code for below condition. if (today=="Monday" ) { while (current_time LESS THAN 9:01 AM) ... (1 Reply)
Discussion started by: ajaypatil_am
1 Replies

9. Shell Programming and Scripting

How to check if date format is correct?

Hi! how do i know if the input is the same as the required date format? the date should be dd/mm/YYYY ex. 2/3/2012 or 15/11/2012 all the following conditions must return an error: *input of string *day is > 31 or < 1 *month is > 12 or < 1 *year is < 2013 suppose the date format is stored... (1 Reply)
Discussion started by: angilulu
1 Replies

10. Shell Programming and Scripting

Check Date Format And Email Out

Hello All, I have a requirement where i need to get the EXTRACT_DATE from a file and check if the date is of valid format or not and then mail it if it is not valid. Appreciate if you can help me with this. I did the following so far. awk '{for(i=1;i++<=NF;)if($i~/^EXTRACT_DATE/) print $i}'... (11 Replies)
Discussion started by: Ariean
11 Replies
LBDB-FETCHADDR(1)						   User Manuals 						 LBDB-FETCHADDR(1)

NAME
lbdb-fetchaddr - grab addresses from mails add append them to lbdb database SYNOPSIS
lbdb-fetchaddr [-d dateformat] [-x headerfieldlist] [-c charset] [-a] lbdb-fetchaddr [-v|-h] DESCRIPTION
lbdb-fetchaddr is a shell script which reads a mail on stdin. It extracts the contents of some header fields (default: `From:', `To:', `Cc:', `Resent-From:', and `Resent-To:') from the mail header (only addresses with a real name) and appends them to $HOME/.lbdb/m_inmail.list. For performance issues lbdb-fetchaddr appends new addresses to this file without removing duplicates. To get rid of duplicates, the program lbdb-munge exists, which is run by m_inmail if needed and removes duplicates. To use this program, put the following lines into your $HOME/.procmailrc: :0hc | lbdb-fetchaddr lbdb-fetchaddr writes the actual date to the third column of the database by using strftime(3). It uses "%Y-%m-%d %H:%M" as the default date format (e.g. "1999-04-29 14:33"). You can change this by using the -d option to select a different date format string as parameter of lbdb-fetchaddr command like :0hc | lbdb-fetchaddr -d "%y-%m-%d" which results in e.g. "99-04-29". OPTIONS
-v Print version number of lbdb-fetchaddr. -h Print short help of lbdb-fetchaddr. -d dateformat Use the given date format using strftime(3) syntax. -x headerfields A colon separated list of header fields, which should be searched for mail addresses. If this option isn't given, we fall back to `from:to:cc:resent-from:resent-to'. -c charset The charset which will be used to write the database. This should be the charset which the application expects (normally the one from your current locale). If this option isn't given, we fall back to `iso-8859-15'. -a Also grab addresses without a real name. Use the local part of the mail address as real name. FILES
$HOME/.lbdb/m_inmail.list /usr/lib/lbdb/fetchaddr /usr/lib/lbdb/m_inmail SEE ALSO
lbdbq(1), lbdb_dotlock(1), procmail(1), procmailrc(5), strftime(3). CREDITS
Most of the really interesting code of this program (namely, the RFC 822 address parser used by lbdb-fetchaddr) was stolen from Michael Elkins' mutt mail user agent. Additional credits go to Brandon Long for putting the query functionality into mutt. AUTHOR
The lbdb package was written by Thomas Roessler <roessler@guug.de> and is now maintained and extended by Roland Rosenfeld <roland@spin- naker.de>. Unix October 2005 LBDB-FETCHADDR(1)
All times are GMT -4. The time now is 02:54 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy