The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > OS Specific Forums > AIX
Google UNIX.COM


AIX AIX is IBM's industry-leading UNIX operating system that meets the demands of applications that businesses rely upon in today's marketplace.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
doubt in tr command risshanth UNIX for Dummies Questions & Answers 2 02-25-2008 07:20 AM
Doubt in SED command gksenthilkumar UNIX for Advanced & Expert Users 1 02-19-2008 11:20 AM
doubt in AWK abnirmal Shell Programming and Scripting 4 05-08-2007 02:27 PM
Pls help for the doubt ravi.sadani19 Shell Programming and Scripting 4 04-12-2007 01:51 AM
Doubt in find command mona Shell Programming and Scripting 3 12-11-2005 09:54 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 01-23-2006
Registered User
 

Join Date: Jan 2006
Posts: 6
doubt in cal command

I am new to unix...

How to get all the saturdays of a specific year?

for a specific month, i tried as below..
cal 02 2006 | awk '{print $7}'
but it is not giving all saturdays....

can anyone help me with this?

Thanks in advance,
Sumi
Reply With Quote
Forum Sponsor
  #2  
Old 01-23-2006
Registered User
 

Join Date: May 2005
Posts: 19
Hi

Try the following command

cal 01 2006 | tr -s " " | sed -e '1,2d' | awk -F" " '{print $1}'



use the following in awk
$1 - For Sundays
$2 - For Mondays
$3 - For Tuesdays
and so on

Hope this helps

Regards
Bobby
Reply With Quote
  #3  
Old 01-23-2006
Registered User
 

Join Date: Jan 2006
Posts: 6
i tried the command u sent...for this command,

cal 02 2006 | tr -s " " | sed -e '1,2d' | awk -F" " '{print $7}'

output should be:
4
11
18
25

but the output i am getting for the above command:
11
18
25
Reply With Quote
  #4  
Old 01-23-2006
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,667
Read the date arithmetic article in our faq section. My datecalc script can do stuff like this:
Code:
#! /usr/bin/ksh

desiredday=$1
year=$2

(( cday = $(datecalc -j $year 1 1) + (($desiredday - $(datecalc -d $year 1 1) + 7)%7) ))
(( limit = $(datecalc -j $year 12 31) ))
while ((cday<limit)) ; do
        datecalc -j $cday
        ((cday=cday+7))
done
exit 0
The first argument is the day of the week (0 - 6) and the second argument is the year.
./script 6 2006 will give you all saturdays for the current year.
Reply With Quote
  #5  
Old 01-27-2006
Registered User
 

Join Date: Jan 2006
Posts: 6
i am using datecalc function....after subtracting 6 from dt1, i am getting
2006 1 15

dt1=2006 01 27
datecalc -a $dt1 - 6

but i want the output as
2006 01 15

i searched the forum... if i get the "day" individually and perform operation, i can use typedef. but i am using the full date and subtracting 6 from it. how to get the desired output as above?
Reply With Quote
  #6  
Old 01-27-2006
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,667
typeset -Z2 month day
datecalc -a $dt1 - 6 | read year month day
echo $year $month $day
Reply With Quote
  #7  
Old 01-31-2006
Registered User
 

Join Date: Jan 2006
Posts: 6
I have one text file which has many date fields.

Date field is in "mm/dd/yyyy" format.

I want to replace every yyyy to yy format.

If i have one year value namely 2005, i can replace as

s/2005/05/g

Since i have many values, how to generalise the the above replacement ?
Through script, i need to grep and replace.

Thanks in advance.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 05:29 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0