The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
work with date function jasonx22 Web Programming, Web 2.0 and Mashups 1 07-19-2008 09:12 AM
Date Function charandevu Shell Programming and Scripting 1 04-02-2008 06:12 AM
Date Function charandevu Shell Programming and Scripting 1 04-02-2008 04:44 AM
date function abey Shell Programming and Scripting 2 02-27-2006 02:28 AM
Yesterday's date function ssmiths001 UNIX for Dummies Questions & Answers 4 01-11-2005 07:06 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 09-03-2008
Registered User
 

Join Date: Jul 2008
Posts: 34
Get date from cal function

Cal
Sun Mon Tue Wed Thu Fri Sat
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

cal | awk '{print $7}'
Sat

13
20
27
In the above output i am missing 6 because the first column is empty so it is shfting.
How can i print all the dates under sat.
I need the output like below.
Sat
6
13
20
27
Reply With Quote
Forum Sponsor
  #2  
Old 09-03-2008
 

Join Date: May 2008
Location: Sydney, Australia
Posts: 920
Use cut to cut out the column by character count.
Reply With Quote
  #3  
Old 09-04-2008
radoulov's Avatar
addict
 

Join Date: Jan 2007
Location: Milano, Italia/Варна, България
Posts: 1,930
Use nawk or /usr/xpg4/bin/awk on Solaris:

Code:
cal|awk '{print/^  /?$NF:$7}'
Reply With Quote
  #4  
Old 09-04-2008
dj -------
 

Join Date: Feb 2007
Location: Cochin/Bangalore, India
Posts: 439
A very ugly way to do this...But the solution suggested by radoulov must be the best way..
Code:
cal | sed -n '/\(.*\) \(.*\) \(.*\) \(.*\) \(.*\) \(.*\) \(.*\)/p' |sed 's/\(.*\) \(.*\)/\2/'
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 01:10 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