Sponsored Content
Top Forums Shell Programming and Scripting Script to validate dates inside a file Post 302935957 by dattatraya on Friday 20th of February 2015 01:53:37 PM
Old 02-20-2015
Thanks for your response.

I am really confused from where i should start .

File contain looks like below, i need to pick the date and compare with system date whether it's T-1 or not from Tuesday to Friday and on Monday T-3

cat ABC.txt
fdhf fdhg r

20/02/2015
fhbredsfie
 

10 More Discussions You Might Find Interesting

1. 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

2. Shell Programming and Scripting

The scope of the shell/perl script is to read the input text file. Validate the expiry date of each

The scope of the shell/perl script is to read the input text file. Validate the expiry date of each certificate and send the mail to the user. The user takes action to add the new certificate to the storage file and user owns the responsibility to update the input text file with the new certificate... (5 Replies)
Discussion started by: casmo
5 Replies

3. Shell Programming and Scripting

ksh compare dates INSIDE a file (ie date A is > date B)

In KSH, I am pasting 2 almost identical files together and each one has a date and time on each line. I need to determine if the first instance of the date/time is greater than the 2nd instance of the date/time. If the first instance is greater, I just need to echo that line. I thought I would... (4 Replies)
Discussion started by: right_coaster
4 Replies

4. Shell Programming and Scripting

Script to validate file header and trailer

Hi, I need a script that validates a file header/detail/trailer. File layout is: Header - Rec_Type|File_name|File_Date Detail - Rec_Type|field1|field2|field3... Trailder - Rec_Type|File_name|File_Date|Record_count Sample Data: HDR|customer_data.dat|20120709... (7 Replies)
Discussion started by: ash_sh
7 Replies

5. Shell Programming and Scripting

Need script to validate file according to date

Hi All, I am very new to unix and just started to work with unix and shell scripting.I have a query anyone help would be much appreciated I am using sun solaris OS I want to validate a file according to its date and if validate successful then it would write the file name,size,date and... (3 Replies)
Discussion started by: sv0081493
3 Replies

6. Shell Programming and Scripting

Script to read a log file and run 2nd script if the dates match

# cat /tmp/checkdate.log SQL*Plus: Release 11.2.0.1.0 Production on Mon Sep 17 22:49:00 2012 Copyright (c) 1982, 2009, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production FIRST_TIME NEXT_TIME... (1 Reply)
Discussion started by: SarwalR
1 Replies

7. Shell Programming and Scripting

Validate file count in korn shell script

Hi, I have files in the directory like below which I need to validate if all the required files are present. A_B_001 of 002_time1.txt A_B_002 of 002_time1.txt A_B_001 of 001_time2.txt Scenarios- a)If file with 001 of 002_time1 or 002 of 002_time1 is missing in the folder,script should... (6 Replies)
Discussion started by: aneeta13
6 Replies

8. Shell Programming and Scripting

Need a ready Shell script to validate a high volume data file

Hi, I am looking for a ready shell script that can help in loading and validating a high volume (around 4 GB) .Dat file . The data in the file has to be validated at each of its column, like the data constraint on each of the data type on each of its 60 columns and also a few other constraints... (2 Replies)
Discussion started by: Guruprasad
2 Replies

9. Shell Programming and Scripting

Need Help:Shell Script for Solaris to change the dates in a file by one week

I have to increase the date by one week in an input when script is executed in solaris. I was able to acheive this using ksh script that is working in Linux enivironment, when i execute the same script in Solaris i am getting below error: /var/tmp\n\r-> ./script.ksh date: illegal option -- d... (3 Replies)
Discussion started by: sriramanaramoju
3 Replies

10. Shell Programming and Scripting

Script to validate header in a csv file

Hi All; I am struggling to write a script that validates file header. Header file would be like below with TAB separated TRX # TYPE REF # Source Piece Code Destination Piece Code every time I need to check the txt file if the header was same as above fields if validation success... (6 Replies)
Discussion started by: heye18
6 Replies
ARRAY_UDIFF(3)								 1							    ARRAY_UDIFF(3)

array_udiff - Computes the difference of arrays by using a callback function for data comparison

SYNOPSIS
array array_udiff (array $array1, array $array2, [array $...], callable $value_compare_func) DESCRIPTION
Computes the difference of arrays by using a callback function for data comparison. This is unlike array_diff(3) which uses an internal function for comparing the data. PARAMETERS
o $array1 - The first array. o $array2 - The second array. o $value_compare_func - The callback comparison function. The comparison function must return an integer less than, equal to, or greater than zero if the first argument is considered to be respectively less than, equal to, or greater than the second. int callback (mixed $a, mixed $b) RETURN VALUES
Returns an array containing all the values of $array1 that are not present in any of the other arguments. EXAMPLES
Example #1 array_udiff(3) example using stdClass Objects <?php // Arrays to compare $array1 = array(new stdclass, new stdclass, new stdclass, new stdclass, ); $array2 = array( new stdclass, new stdclass, ); // Set some properties for each object $array1[0]->width = 11; $array1[0]->height = 3; $array1[1]->width = 7; $array1[1]->height = 1; $array1[2]->width = 2; $array1[2]->height = 9; $array1[3]->width = 5; $array1[3]->height = 7; $array2[0]->width = 7; $array2[0]->height = 5; $array2[1]->width = 9; $array2[1]->height = 2; function compare_by_area($a, $b) { $areaA = $a->width * $a->height; $areaB = $b->width * $b->height; if ($areaA < $areaB) { return -1; } elseif ($areaA > $areaB) { return 1; } else { return 0; } } print_r(array_udiff($array1, $array2, 'compare_by_area')); ?> The above example will output: Array ( [0] => stdClass Object ( [width] => 11 [height] => 3 ) [1] => stdClass Object ( [width] => 7 [height] => 1 ) ) Example #2 array_udiff(3) example using DateTime Objects <?php class MyCalendar { public $free = array(); public $booked = array(); public function __construct($week = 'now') { $start = new DateTime($week); $start->modify('Monday this week midnight'); $end = clone $start; $end->modify('Friday this week midnight'); $interval = new DateInterval('P1D'); foreach (new DatePeriod($start, $interval, $end) as $freeTime) { $this->free[] = $freeTime; } } public function bookAppointment(DateTime $date, $note) { $this->booked[] = array('date' => $date->modify('midnight'), 'note' => $note); } public function checkAvailability() { return array_udiff($this->free, $this->booked, array($this, 'customCompare')); } public function customCompare($free, $booked) { if (is_array($free)) $a = $free['date']; else $a = $free; if (is_array($booked)) $b = $booked['date']; else $b = $booked; if ($a == $b) { return 0; } elseif ($a > $b) { return 1; } else { return -1; } } } // Create a calendar for weekly appointments $myCalendar = new MyCalendar; // Book some appointments for this week $myCalendar->bookAppointment(new DateTime('Monday this week'), "Cleaning GoogleGuy's apartment."); $myCalendar->bookAppointment(new DateTime('Wednesday this week'), "Going on a snowboarding trip."); $myCalendar->bookAppointment(new DateTime('Friday this week'), "Fixing buggy code."); // Check availability of days by comparing $booked dates against $free dates echo "I'm available on the following days this week... "; foreach ($myCalendar->checkAvailability() as $free) { echo $free->format('l'), " "; } echo " "; echo "I'm busy on the following days this week... "; foreach ($myCalendar->booked as $booked) { echo $booked['date']->format('l'), ": ", $booked['note'], " "; } ?> The above example will output: I'm available on the following days this week... Tuesday Thursday I'm busy on the following days this week... Monday: Cleaning GoogleGuy's apartment. Wednesday: Going on a snowboarding trip. Friday: Fixing buggy code. NOTES
Note Please note that this function only checks one dimension of a n-dimensional array. Of course you can check deeper dimensions by using array_udiff($array1[0], $array2[0], "data_compare_func");. SEE ALSO
array_diff(3), array_diff_assoc(3), array_diff_uassoc(3), array_udiff_assoc(3), array_udiff_uassoc(3), array_intersect(3), array_inter- sect_assoc(3), array_uintersect(3), array_uintersect_assoc(3), array_uintersect_uassoc(3). PHP Documentation Group ARRAY_UDIFF(3)
All times are GMT -4. The time now is 11:55 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy