Sponsored Content
Top Forums Shell Programming and Scripting [DATE] Pattern matching notation Post 302777971 by Yoda on Saturday 9th of March 2013 01:18:01 AM
Old 03-09-2013
Even if you fix this pattern, I don't think it will be reliable because this will not cover conditions like leap year.

So If you have GNU date, you can simply do:
Code:
[[ "$( date -d "$1" +%F 2>&1 | grep invalid )" = "" ]] && echo "$1 is valid" || echo "$1 is invalid"

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

comment/delete a particular pattern starting from second line of the matching pattern

Hi, I have file 1.txt with following entries as shown: 0152364|134444|10.20.30.40|015236433 0233654|122555|10.20.30.50|023365433 ** ** ** In file 2.txt I have the following entries as shown: 0152364|134444|10.20.30.40|015236433 0233654|122555|10.20.30.50|023365433... (4 Replies)
Discussion started by: imas
4 Replies

2. Shell Programming and Scripting

counting the lines matching a pattern, in between two pattern, and generate a tab

Hi all, I'm looking for some help. I have a file (very long) that is organized like below: >Cluster 0 0 283nt, >01_FRYJ6ZM12HMXZS... at +/99% 1 279nt, >01_FRYJ6ZM12HN12A... at +/99% 2 281nt, >01_FRYJ6ZM12HM4TS... at +/99% 3 283nt, >01_FRYJ6ZM12HM946... at +/99% 4 279nt,... (4 Replies)
Discussion started by: d.chauliac
4 Replies

3. Shell Programming and Scripting

pattern matching lines using the date, and then joining the lines

Hi Guys, Was trying to attempt the below using awk and sed, have no luck so far, so any help would be appreciated. Current Text File: The first line has got an "\n", and the second line has got spaces/tabs then the word and "\n" TIME SERVER/CLIENT TEXT... (6 Replies)
Discussion started by: eo29
6 Replies

4. Shell Programming and Scripting

Convert decimal notation to ANSI point code notation

wondering if anyone has any thoughts to convert the below thru a shell script Convert decimal signalling point notation to ANSI point code notation There is a site that does that conversion but i need to implement the solution in a shell script.....Thoughts.... OS: Solaris 9 ... (4 Replies)
Discussion started by: aavam
4 Replies

5. Shell Programming and Scripting

Pattern matching notation

Hello, I want to match this patterns IS01ORA IS02ORA ... ... IS08ORA With that : ISORA But it doesn't work, can you correct it ? Thanks (8 Replies)
Discussion started by: amazigh42
8 Replies

6. Shell Programming and Scripting

Pattern matching notation

Hello, I want to simplify two commands into one. 1st command $type_log_$instance.log.$date.0012nd command $type_log.log.$date.tar.gzInto blue brackets, How do I do to replace the pattern by a blank or _$instance ? $type_log?_$instance].log.$date.*Thank you. (13 Replies)
Discussion started by: amazigh42
13 Replies

7. Shell Programming and Scripting

Pattern matching notation

Hello I have two kinds of logs like server.logserver.log.2013-07-27.001i want to create a variable which look like this (with a pipe) log_name=server.(log|log.$YYYY-MM-DD.)But i tried many cases but it didn't work. Is it possible ? If yes, can you help me. (6 Replies)
Discussion started by: amazigh42
6 Replies

8. Shell Programming and Scripting

Perl: scientific notation to decimal notation

hello folks, I have few values in a log which are in scientific notation. I am trying to convert into actual decimal format or integer but couldn't able to convert. Values in scientific notation: 1.1662986666666665E-4 2.0946799999999998E-4 3.0741333333333333E-6 5.599999999999999E-7... (2 Replies)
Discussion started by: scriptscript
2 Replies

9. Shell Programming and Scripting

Sed: printing lines AFTER pattern matching EXCLUDING the line containing the pattern

'Hi I'm using the following code to extract the lines(and redirect them to a txt file) after the pattern match. But the output is inclusive of the line with pattern match. Which option is to be used to exclude the line containing the pattern? sed -n '/Conn.*User/,$p' > consumers.txt (11 Replies)
Discussion started by: essem
11 Replies

10. Shell Programming and Scripting

PHP - Regex for matching string containing pattern but without pattern itself

The sample file: dept1: user1,user2,user3 dept2: user4,user5,user6 dept3: user7,user8,user9 I want to match by '/^dept2.*/' but don't want to have substring 'dept2:' in output. How to compose such regex? (8 Replies)
Discussion started by: urello
8 Replies
lunar(1)						      General Commands Manual							  lunar(1)

NAME
lunar (version 2.2) - a calendar conversion utility SYNTAX
lunar [ -h ] [ -b ] [ -i ] [ -l ] year month day [ hour ] DESCRIPTION
The program performs date conversion between the Gregorian Solar Calendar (SC) and the Chinese Lunar Calendar (LC). Given a date in either calendar, the program also outputs the corresponding "shengxiao" (animal of the year) and "ganzhi" characters. The date range currently covered is from about 1900 A.D. to 2049 A.D. For the sake of convenience, we choose the convention such that the solar and lunar year numbers of the first day of a lunar year are the same. For example, SC 1991.2.15 is LC 1991.1.1, while SC 1991.2.14 is LC 1990.12.30. Moreover, we choose the convention such that the solar and lunar hour numbers (in 24-hour clock) of a date are the same, although a lunar day starts at 23:00 of a solar day. This means that SC 1991.2.15.23 is LC 1991.1.2.23, while SC 1991.2.16.0 is LC 1991.1.2.0, and SC 1991.2.16.1 is LC 1991.1.2.1. The standard time of the Lunar Calendar is Beijing (Hong Kong) Standard Time, not GMT. Be sure to adjust appropriately for other time zones and "Daylight Saving Time". In the Lunar Calendar, a normal year has 12 months, and a leap year (run-nian) has 13 months, where the extra month is called a "leap month" (run-yue). For example, the leap month that follows immediately the 6-th lunar month is called the 6-th leap month. A (leap) month is either a short or long one, which has 29 or 30 days respectively. There are 10 gan's and 12 zhi's. The ganzhi labeling of the year, month, day and hour of a date is a member of the Cartesian product GxGxGxG, where G = {1,2,...,60}. For example, "jia-zi" is 1, "yi-chou" is 2, and so on. The ganzhi of the j-th leap month is the same as that of the j-th month. The possible options are b output ganzhi in special "bitmap" characters. h output hanzi or Chinese characters encoded in (highest-bit-set) GB code. i convert a lunar date to solar date. The default is to convert a solar date to a lunar date. l indicate the month is a lunar leap month. This option is meaningful only when the "-i" option is used. COPYRIGHT
Copyright (C) 1988, 1989, 1991, 1992, 2001 Fung F. Lee and Ricky Yeung This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MER- CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. The last version of this program was released on July 23, 1992 as version 2.1a. This program was first released under the terms of GNU GPL on October 28, 2001 as version 2.2. Both versions are identical except for the license text. AUTHORS
Fung F. Lee and Ricky Yeung ACKNOWLEDGEMENT
The special "bitmap" file "lunar.bitmap" was contributed by Weimin Liu. Special thanks to Hwei Chen Ti who extended the tables from 2001 to 2049. BUGS
Bug reports and comments should be sent to lee@umunhum.stanford.edu. DISCLAIMER
This software has no connection with our employers. 28 October 2001 lunar(1)
All times are GMT -4. The time now is 02:35 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy