The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
pickup until last friday files from directory magi Shell Programming and Scripting 1 12-14-2007 03:26 PM
IBM to ship new AIX 6 Unix on Friday - Computerworld iBot UNIX and Linux RSS News 0 11-06-2007 04:20 PM
how can i find the third friday of each month? leslie02 Shell Programming and Scripting 10 05-31-2007 09:45 AM
Friday afternoon headache _Spare_Ribs_ Shell Programming and Scripting 4 12-18-2006 10:38 AM
quoting echo 'it's friday' yls177 UNIX for Dummies Questions & Answers 3 09-19-2002 11:09 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-07-2006
LAY LAY is offline
Registered User
  
 

Join Date: Oct 2006
Posts: 4
Need help, Every friday in a month

I am trying to write a script that shows every Friday in a month.
I used
cal $1 $2 | grep -v "^$" | awk '{print $6}'

It doesn't work for the frist week of Friday because calendar command output has some spaces in the first line and awk '{print $6}' doesn't work. Anybody help
me with this problem?
  #2 (permalink)  
Old 12-07-2006
reborg's Avatar
reborg reborg is offline Forum Staff  
Administrator
  
 

Join Date: Mar 2005
Location: Ireland
Posts: 4,206
cal $1 $2 | awk 'NR >2 { print substr($0,16,2)}'
  #3 (permalink)  
Old 12-09-2006
bishweshwar bishweshwar is offline
Registered User
  
 

Join Date: Sep 2006
Posts: 56
Quote:
Originally Posted by reborg
cal $1 $2 | awk 'NR >2 { print substr($0,16,2)}'
I couldn't get how this command works. Can you just explain it's function......
  #4 (permalink)  
Old 12-09-2006
cskumar cskumar is offline
Registered User
  
 

Join Date: Oct 2005
Posts: 67
explanation

command
cal 12 2006
Note:The result has not aligned properly,check in your OS box.
EDIT -- It is aligned now because I added code tags and restored the original spacing of the output. -- Perderabo
Code:
   December 2006
 S  M Tu  W Th  F  S
                1  2
 3  4  5  6  7  8  9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31
the dates start from 3rd line,thats why he is omitting the first two lines by checking the condition line number greater than 2. NR >2

then starting from 3rd line get the starting character as 16 and number of characters as 2,as Friday dates starts from 16th character (fixed ).

Regards,
cskumar.

Last edited by Perderabo; 12-09-2006 at 10:35 AM.. Reason: Add code tags for readability
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:08 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0