Sponsored Content
Top Forums Shell Programming and Scripting Getting week number of the "Monday" Post 302095379 by sbasetty on Monday 6th of November 2006 02:10:58 PM
Old 11-06-2006
Getting week number of the "Monday"

Hi Friends,

Can you help me with this,
I would like to get the week number of the "Monday",
Say if we run on first week of november it should give me output as "05" and "10" i.e it says the monday falls on 5th week of october.
If we run on the second week of november it should give me "01" and "11".
Says Monday falls on 1st week of november.

Any help is highly appreciated.

Thanks in advence. Smilie
S

Last edited by sbasetty; 11-07-2006 at 09:18 PM..
 

7 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies

2. HP-UX

[Solved] crontab issue "day of week"

Is there an issue with running a cron entry like the below entries? 0 2 21 12 2 cd /usr/local/bin;./cksecurity.sh -f /home/theninja/security.dat21 I wanted this to run on Tues at 2am, which it did successfully, however I also had the following entry to run next tuesday that also ran on 12/21.... (3 Replies)
Discussion started by: theninja
3 Replies

3. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

4. Solaris

The slices "usr", "opt", "tmp" disappeared!!! Help please.

The system don't boot. on the screen appears following: press enter to maintenance (or type CTRL-D to continue)...I checked with format command. ... the slices "0-root","1-swap","2-backup" exist. ...the slises "3-var","6-usr" -unassigned. :( (16 Replies)
Discussion started by: wolfgang
16 Replies

5. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

6. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

7. AIX

Apache 2.4 directory cannot display "Last modified" "Size" "Description"

Hi 2 all, i have had AIX 7.2 :/# /usr/IBMAHS/bin/apachectl -v Server version: Apache/2.4.12 (Unix) Server built: May 25 2015 04:58:27 :/#:/# /usr/IBMAHS/bin/apachectl -M Loaded Modules: core_module (static) so_module (static) http_module (static) mpm_worker_module (static) ... (3 Replies)
Discussion started by: penchev
3 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 01:20 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy