Sponsored Content
Top Forums Shell Programming and Scripting How to get the consecutive last 10 week day date using UNIX ksh shell scripting? Post 302881749 by Blackacid on Tuesday 31st of December 2013 03:08:45 PM
Old 12-31-2013
you want to run through a count starting from 0-9 (10), stepping back each iteration as a day in time. Then you want to identify any day that might be a Saturday or Sunday? I think this will work?



Code:
counter=0

while [[ $counter -le 9 ]]
 do
   case $counter in
        [0-9])
          LDATE=`date -d "$counter days ago" +%Y%m%d`
          DOW=`date -d $LDATE +%u`

          case $DOW in
             7)
                DAY="Sunday";;
             6)
                DAY="Saturday";;
             *)
                DAY="Mon - Fri";;
          esac;;
   esac

   echo "$LDATE - $DAY - $counter"

   (( counter += 1 ))
 done

This User Gave Thanks to Blackacid For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to find Day of the Week from the given date (Perl)?

How to find the Day of the Week of the given Date using perl? If I have a date in YYY--MM-DD format, how to find the DOW? Based on that, I need to find the following sunday. Pls help. (5 Replies)
Discussion started by: deepakwins
5 Replies

2. HP-UX

Get Day of Week from date

Hi All, I have date in string format 'YYYY-MM-DD'. I want to know day of the week for this date. Example. For '2005-08-21' my script should return '0' or Sunday For '2005-08-22' it should return '1' or Monday I want piece of code for HP-UX korn shell. Appreciate reply on this. (5 Replies)
Discussion started by: vpapaiya
5 Replies

3. Shell Programming and Scripting

Display the day of the given date-ksh

Hi friends, I need some urgent help on Dates in unix. I have a date say - "20080706", i need some command to display the day, here its sunday(06). Please help me out. FYI: I use Ksh. I/P - 20080706 O/P - Sunday (1 Reply)
Discussion started by: divzz
1 Replies

4. Shell Programming and Scripting

Function to get day of week from YYYY-MM-DD date

Can't find out how to get the day of the week from a given date, anyone got a code snippet that could help please? Ta!! (4 Replies)
Discussion started by: couponmeup
4 Replies

5. Shell Programming and Scripting

how to obtain date and day of the week from `date` command

Hi, does anybody know how to format `date` command correctly to return the day of the week? Thanks -A I work in ksh.... (1 Reply)
Discussion started by: aoussenko
1 Replies

6. Shell Programming and Scripting

Finding Day of the week from date

I have a problem of Finding Day of the week from date, but i need to do it within awk On SOLARIS Input:20101007(YYYYMMDD) Output:Thursday kindly provide suggestions. Thanks in advance (8 Replies)
Discussion started by: junaid.nehvi
8 Replies

7. Shell Programming and Scripting

How to add trailer record at the end of the flat file in the unix ksh shell scripting?

Hi, How to add trailer record at the end of the flat file in the unix ksh shell scripting can you please let me know the procedure Regards Srikanth (3 Replies)
Discussion started by: srikanth_sagi
3 Replies

8. Shell Programming and Scripting

How to add day of week at the end of each line that shows the date?

I have a file that looks like: file1: www_blank_com 20121008153552 www_blank_com 20121008162542 www_blank_com 20121009040540 www_blank_com 20121009041542 www_blank_com 20121010113548 www_blank_com 20121011113551 www_blank_com 20121012113542 I want the new file to show the day of... (3 Replies)
Discussion started by: castrojc
3 Replies

9. Shell Programming and Scripting

How to obtain a day of the week from the date?

I have a date in format YYYYMMDD, i need to get the day of the week from the given date. I am working in AIX system. ---------- Post updated at 09:59 AM ---------- Previous update was at 09:57 AM ---------- Tried to post sum of the thread's link from which i tried, but de rules didnt allow me... (9 Replies)
Discussion started by: baranisachin
9 Replies

10. Shell Programming and Scripting

Delete all CONSECUTIVE text lines from file shell scripting

Hi I have a text file like below. THe content of the text will vary. Entire text file have four consecutive lines followed with blank line. I want to delete the occurrence of the two consicutive lines in the text file. I don't have pattern to match and delete. Just i need to delete all... (5 Replies)
Discussion started by: RJSKR28
5 Replies
MooseX::AttributeHelpers::Trait::Counter(3pm)		User Contributed Perl Documentation	     MooseX::AttributeHelpers::Trait::Counter(3pm)

NAME
MooseX::AttributeHelpers::Counter - simple counter attribute SYNOPSIS
package MyHomePage; use Moose; use MooseX::AttributeHelpers; has 'counter' => ( metaclass => 'Counter', is => 'ro', isa => 'Num', default => sub { 0 }, provides => { inc => 'inc_counter', dec => 'dec_counter', reset => 'reset_counter', } ); my $page = MyHomePage->new(); $page->inc_counter; # same as $page->counter($page->counter + 1); $page->dec_counter; # same as $page->counter($page->counter - 1); DESCRIPTION
This module provides a simple counter attribute, which can be incremented and decremeneted. If your attribute definition does not include any of is, isa, default or provides but does use the "Counter" metaclass, then this module applies defaults as in the "SYNOPSIS" above. This allows for a very basic counter definition: has 'foo' => (metaclass => 'Counter'); $obj->inc_foo; METHODS
meta method_provider has_method_provider helper_type process_options_for_provides Run before its superclass method. check_provides_values Run after its superclass method. PROVIDED METHODS
It is important to note that all those methods do in place modification of the value stored in the attribute. set Set the counter to the specified value. inc Increments the value stored in this slot by 1. Providing an argument will cause the counter to be increased by specified amount. dec Decrements the value stored in this slot by 1. Providing an argument will cause the counter to be increased by specified amount. reset Resets the value stored in this slot to it's default value. BUGS
All complex software has bugs lurking in it, and this module is no exception. If you find a bug please either email me, or add the bug to cpan-RT. AUTHOR
Stevan Little <stevan@iinteractive.com> COPYRIGHT AND LICENSE
Copyright 2007-2009 by Infinity Interactive, Inc. <http://www.iinteractive.com> This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.10.1 2010-01-02 MooseX::AttributeHelpers::Trait::Counter(3pm)
All times are GMT -4. The time now is 06:34 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy