test.txt
====
previously i used for loop to find the date check like below,
but it is taking so much time when the file has 7000 records,i need a command to find the whetehr any invalid date is there in the file.if any one of the date is invalid i need to return a flag.
please help asap.
Last edited by Franklin52; 11-11-2013 at 05:57 PM..
Reason: Please use code tags
You call many external commands (cut, sed etc.) which all take take to start a sub process and this is what is costing you.
I'm aware that date -d is not available in all implementations. What OS are you using?
Trying to avoid being OS specific (and not the neatest code) could you consider this:-
If you can be sure that you don't actually have any / as date separators in your input (as you posted, possibly in error) then it simplifies to just:-
I'm not quite sure what you are trying with the remainder. Are you trying to validate that it is an acceptable date?
If you are sure you are getting just numerics, that might be better as a case statement like this:-
Of course, if you are just looking for the right format, then:-
I hope that this helps,
Robin
Liverpool/Blackburn
UK
my requirement is that in a file only dates will be there, in that i have to find whether any invalid date is there. if any invalid date is there i have to just get the result the file is invalid.
the correct format of date is "2011-03-13"(YYYY-MM-DD).
Okay, so I can refine simple grep then apply the other parts in sequence. The first test is for basic structural validation, then it follows with a date check without calling date or cal which will slow down processing on a large file too.
The echo statements man need to be replaced with printf depending on your OS.
I must say that I like the Python way, if you have that.
Additionally, if you have a database, that may have similar tools.
so i have scripts that get run in ways similar to this:
cat script.pl | perl - $1 $2 $3
cat script.rb | ruby - $1 $ 2 $3
my question is, how can i verify that that the "perl" or "ruby" or "python" tool being run on the box is actually a legit tool? meaning, someone may move the tool from... (2 Replies)
hello,
in a file exist entries in date format YYYYMMDD. i want to find out, if there are dates, which isn't today's date.
file:
date example text
20140714 <= not today's date
20140715 <= not today's date
20140716 <= today's date
my idea is to use Perderabo's datecalc
... (2 Replies)
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)
Hi,
In a field, I should receive the date with time stamp in a particular field. But sometimes the vendor sends just the date or the timestamp or correctl the date×tamp. I have to figure out the the data is a date or time stamp or date×tamp.
If it is date then append "<space>00:00:00"... (1 Reply)
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)
Hi,
I have to validate the passwords for 100s of unix users across several servers. I have the list of unix users and servers with passwrods.
How can I check whether a password is correct or not using a single shell script?
Note : I do not have root privileges on any server. All the... (1 Reply)
How to validate the first line from 1-8 position of audit file that contains the script run date... script could run in random dates.
head -1 file1
20090516 100034837SHDHSHE (9 Replies)
Hi folks,
I need to write a script that should activate a process according to the current hour.
The process should be activatet only if the hour is between midnight (00:00) and 07:00.
How should I create the condition?
Thanks in advance,
Nir (2 Replies)
hi, i'm trying to write a script to check if the home directories of users are set correctly. below is an extract of the script
here, i am trying to put the name of the owner of the home directory into the variable dirperm (by reading lines in /etc/passwd). however, it seems that when the... (1 Reply)
Hey, I was wondering how I could write a bash script which accepts:
cat <<% | bash ./results06
----------------------------------------------------------
Exam Results 2006
----------------------------------------------------------
... (1 Reply)