Sponsored Content
Full Discussion: Awk/sed to play on calender
Top Forums UNIX for Dummies Questions & Answers Awk/sed to play on calender Post 302748113 by RudiC on Monday 24th of December 2012 09:36:11 AM
Old 12-24-2012
Not sure if this is worth the while...:
Code:
$ for DAY in {1..31}
   do
      cal 10 1987|awk -v day=$DAY \
          'NR==1{next}
           NR==2 {split ($0, WD); next}
           match ($0, "(^| )"day" ") {print day,WD[ int((4+RSTART-RSTART%2)/3)]}
          '
   done
1 Th
2 Fr

You can squeeze all of this into one single line, of course, as e.g. NR==1 can be omitted and the variables can be one letter only, but readability may suffer... see yourself:
Code:
cal 10 1987|awk -v D=$1 'NR==2 {split($0,WD)} R=match($0,"(^| )"D" ") {print WD[int((4+R-R%2)/3)]}'


Last edited by RudiC; 12-24-2012 at 10:41 AM..
 

10 More Discussions You Might Find Interesting

1. Programming

C Calender Help - Unusual error

I'm making a program that you input the month and year, and it creates a calender for that month of that year. This is my largest project yet, and I broke it up into several source files. cal.c #include "cal.h" #include <stdio.h> main() { int month, year; scanf("%d %d", &month,... (3 Replies)
Discussion started by: Octal
3 Replies

2. Shell Programming and Scripting

convert Julian date to calender date

Hi, I have script in unix which creates a julian date like 126 or 127 I want convert this julian date into calender date ex : input 127 output 07/may/2007 or 07/05/2007 or 07/05/07 rgds srikanth (6 Replies)
Discussion started by: srikanthus2002
6 Replies

3. Shell Programming and Scripting

Calender Unix programming date issues

Hi, i;m beginner of Unix, i trying to use crontab to zip my log file automatically, below is my coding, some of the statement i don't know whether is correct or not. Pls help:) year=`date '+%Y'` month=`date '+%m'` day=`date '+%d'` day=`expr $day - 1` case $month in 1 | 3 | 5 | 7 | 8 | 9 |... (4 Replies)
Discussion started by: dannyd_y
4 Replies

4. Fedora

Script to find out first day of our calender

I try to find the first day of our calender. So I used this script ... echo -n "The week of the date 01jan0001 : " echo -n `date -d 00010101 +%A` echo But its shows error bash-3.1$ sh first_day.shThe week of the date 01jan0001 : date: invalid date `00010101' (3 Replies)
Discussion started by: krishnampkkm
3 Replies

5. Shell Programming and Scripting

Question on Autosys calender date.

Hi I am trying to schedule a job through Autosys through UNIX on a particular day of every month (for example 20th of every month). Can some one please help me whats the command or whats the process to run on that particular day of month. Thank you, (2 Replies)
Discussion started by: sravuri
2 Replies

6. Shell Programming and Scripting

Awk with Find and play using Space

Hi All, Sample records 2157 91128 -rw-r----- 1 arun1 staff 93315072 Aug 23 06:44 /home/arun/my own/file_name.txt 2157 91128 -rw-r----- 1 arun1 staff 93315072 Aug 23 06:44 /home/arun/myown/file name2.txt i want to print only user name, user group, size, date time stamp, and... (5 Replies)
Discussion started by: Arunprasad
5 Replies

7. UNIX and Linux Applications

Calender/docket software

We are running in a Linux/Samba environment. Can anyone suggest calendar/docket software that will run in our environment? (0 Replies)
Discussion started by: kbweiss
0 Replies

8. Shell Programming and Scripting

Enter number of days and get calender

Friends need assistance in getting a script either on shell or perl. Below is the situation Taking Today's calender into consideration with Month,Day,Year current .Using that i would like give number of days to get its month,day,year for future or past calender depending on the + or - days... (8 Replies)
Discussion started by: ajayram_arya
8 Replies

9. Shell Programming and Scripting

Facing problem while having time popup from inline calender

I have CGI Perl script that contains date column and date popup will be displayed from inline calender. I had a html script for the same and converted the same to CGI script. html page worked fine but no luck with CGI script. Could anyone please look into the below script and let me know... (1 Reply)
Discussion started by: scriptscript
1 Replies

10. Shell Programming and Scripting

sed and awk giving error ./sample.sh: line 13: sed: command not found

Hi, I am running a script sample.sh in bash environment .In the script i am using sed and awk commands which when executed individually from terminal they are getting executed normally but when i give these sed and awk commands in the script it is giving the below errors :- ./sample.sh: line... (12 Replies)
Discussion started by: satishmallidi
12 Replies
Prima::Calendar(3)					User Contributed Perl Documentation					Prima::Calendar(3)

NAME
Prima::Calendar - standard calendar widget SYNOPSIS
use Prima::Calendar; my $cal = Prima::Calendar-> create( useLocale => 1, onChange => sub { print $_[0]-> date_as_string, " "; }, ); $cal-> date_from_time( localtime ); $cal-> month( 5); DESCRIPTION
Provides interactive selection of date between 1900 and 2099 years. The main property, date, is a three-integer array, day, month, and year, in the format of perl localtime ( see "localtime" in perlfunc ) - day can be in range from 1 to 31,month from 0 to 11, year from 0 to 199. API
Events Change Called when the date property is changed. Properties date DAY, MONTH, YEAR Accepts three integers in format of "localtime". DAY can be from 1 to 31, MONTH from 0 to 11, YEAR from 0 to 199. Default value: today's date. day INTEGER Selects the day in month. firstDayOfWeek INTEGER Selects the first day of week, an integer between 0 and 6, where 0 is Sunday is the first day, 1 is Monday etc. Default value: 0 month Selects the month. useLocale BOOLEAN If 1, the locale-specific names of months and days of week are used. These are read by calling "POSIX::strftime". If invocation of POSIX module fails, the property is automatically assigned to 0. If 0, the English names of months and days of week are used. Default value: 1 See also: date_as_string year Selects the year. Methods can_use_locale Returns boolean value, whether the locale information can be retrieved by calling "strftime". month2str MONTH Returns MONTH name according to useLocale value. make_months Returns array of 12 month names according to useLocale value. day_of_week DAY, MONTH, YEAR, [ USE_FIRST_DAY_OF_WEEK = 1 ] Returns integer value, from 0 to 6, of the day of week on DAY, MONTH, YEAR date. If boolean USE_FIRST_DAY_OF_WEEK is set, the value of "firstDayOfWeek" property is taken into the account, so 0 is a Sunday shifted forward by "firstDayOfWeek" days. The switch from Julian to Gregorian calendar is ignored. date_as_string [ DAY, MONTH, YEAR ] Returns string representation of date on DAY, MONTH, YEAR according to useLocale property value. date_from_time SEC, MIN, HOUR, M_DAY, MONTH, YEAR, ... Copies date from "localtime" or "gmtime" result. This helper method allows the following syntax: $calendar-> date_from_time( localtime( time)); AUTHOR
Dmitry Karasik, <dmitry@karasik.eu.org>. SEE ALSO
Prima, Prima::Widget, POSIX, "localtime" in perlfunc, "time" in perlfunc, examples/calendar.pl. perl v5.14.2 2009-02-24 Prima::Calendar(3)
All times are GMT -4. The time now is 04:41 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy