Sponsored Content
Top Forums Shell Programming and Scripting Getting a specific date from cal output with AWK Post 302380933 by SFNYC on Wednesday 16th of December 2009 04:57:22 PM
Old 12-16-2009
If you have Perl and the Date::Manip module installed you can try this:

Code:
$ perl -le 'use Date::Manip;print UnixDate(ParseDate("1st Monday in December 2009"), "%d");'
07

$ perl -le 'use Date::Manip;print UnixDate(ParseDate("3rd Friday in December 2009"), "%d");'
18

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Formating cal output

Hi Gurus, In my Cal output i want to cut the date of 2nd saturday how tyo achive this. for eg in the below output i need that second saturday 13 to be cut. crypto $ cal January 2007 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... (2 Replies)
Discussion started by: Krrishv
2 Replies

2. UNIX for Advanced & Expert Users

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... (3 Replies)
Discussion started by: ukatru
3 Replies

3. Red Hat

how to print date/cal in /etc/motd on linux server

helo i want to show today date and calendar when v succesfuly login on the system on the linux server please orovide the sol for the same thanx :):):) (1 Reply)
Discussion started by: dodasajan
1 Replies

4. Shell Programming and Scripting

awk statement to find events from a specific date

I have a script which archives log file events which are 90-days old. Script works fine but I wanted some input on one aspect of this script. My nawk statement, bolded below, that removes events 90-days prior from today, I need it to find anything 90-days or older. The log file date pattern looks... (0 Replies)
Discussion started by: numele
0 Replies

5. Shell Programming and Scripting

Center output of 'cal' command in terminal

I have a function to center output in a terminal. However It only works for variables. I would like to center the output of the command 'cal' or 'cal -3' in a terminal. I have tried: center `cal` CAL=`cal`; center $CAL cal > cal.txt; center `cat cal.txt` center "`exec cal`" To no avail,... (10 Replies)
Discussion started by: AlphaLexman
10 Replies

6. Shell Programming and Scripting

awk assign output of array to specific field-number

With this script i want to print the output to a specific field-number . Can anybody help? awk 'NR=FNR{split(FILENAME,fn,"_");nr=$2;f = $1} END{for (i=1;i<=f;i++) print i,$fn=nr}' input_5.csv input_6.csvinput_5.csv 4 135 5 185 6 85 11 30input_6.csv 1 90 3 58 4 135 7 60 8 55 10... (1 Reply)
Discussion started by: sdf
1 Replies

7. Shell Programming and Scripting

Find and print specific date with awk

hi all I would like to help me find the problem with this script to find and print to the screen a specific date of a log file that I have on my server, the date it is received as the first argument in the script $ 1 Here I show you a few lines that made ​​the idea of ​​my log file: ****... (4 Replies)
Discussion started by: gilmore666
4 Replies

8. Shell Programming and Scripting

AWK specific output filename

Hi All, I'd like to create a specific output filename for AWK. The file I am processing with AWK looks like: output_081012.csv* 27*TEXT*1.0*2.0*3.0 where * is my delimeter and the first line of the file is the output filename i'd like to create is there a way to assign an awk... (10 Replies)
Discussion started by: LMSteed
10 Replies

9. Shell Programming and Scripting

awk to output specific matches in file

Using the attached file, the below awk command results in the output below: I can not seem to produce the desired results and need some expert help. Thank you :). awk -F'' ' { id += $4 value += $5 occur++ } END{ printf "%-8s%8s%8s%8s\n", "Gene", "Targets", "Average Depth", "Average... (3 Replies)
Discussion started by: cmccabe
3 Replies

10. Shell Programming and Scripting

awk to output match and mismatch with count using specific fields

In the below awk I am trying output to one file those lines that match between $2,$3,$4 of file1 and file2 with the count in (). I am also trying to output those lines that are missing between $2,$3,$4 of file1 and file2 with the count of in () each. Both input files are tab-delimited, but the... (7 Replies)
Discussion started by: cmccabe
7 Replies
Date::Manip::Lang(3pm)					User Contributed Perl Documentation				    Date::Manip::Lang(3pm)

NAME
Date::Manip::Lang - language support for Date::Manip DESCRIPTION
Date::Manip supports a number of different languages when parsing dates, and more can be added. CURRENT LANGUAGES
Currently, the following languages are supported by Date::Manip. The version of Date::Manip where they were added is included (so you can see the minimum version of Date::Manip needed to parse each). The language can be chosen by setting the Language config variable to the name of the language or any of the aliases included in the table. All names and aliases are case insensitive. Language Version Aliases English default en, en_us Catalan 5.43 ca Danish 5.41 da Dutch 5.32 Nederlands, nl Finnish 6.31 fi, fi_fi French 5.02 fr, fr_fr German 5.31 de, de_de Italian 5.35 it, it_it Norwegian 6.21 nb, nb_no Polish 5.32 pl, pl_pl Portuguese 5.34 pt, pt_pt Romanian 5.35 ro, ro_ro Russian 5.41 ru, ru_ru Spanish 5.33 es, es_es Swedish 5.05 sv Turkish 5.41 tr, tr_tr ADDING A LANGUAGE
Adding a language is easily done (if you're fluent in both English and the other language). If you want to add a new language, do the following: Language name When you submit the new language, I'll need the name of the language (of course) and any common locale names that might be useful for people to select the language. For example, if you were creating a Spanish translation (which is not necessary since it already exists), I would need the following list: spanish es es_es Copy the english module Copy the english.pm file (which is in lib/Date/Manip/Lang in the Date::Manip distribution) to the new language (i.e. spanish.pm in this example). Set some variables in the new module The new module (spanish.pm) will need a few simple modifications. Change the package name from 'english' to 'spanish'. Fix the @Encodings lines. Most languages can be written in more than one encoding. The first encoding in the list should be utf-8 and the last should be perl. Include any other encodings that should be supported as well. Set the $YearAdded and $LangName appropriately. Translate the language terms Translate all of the data (after the __DATA__ line). The data section of the module (which is written in YAML) is fairly straightforward to translate. Every term is defined in the Date::Manip::Lang::english document (or in any of the other language module documents), so please refer to it to find out what each element means. Then replace the English version with the new translation. There are some requirements: 1) Every element should be defined (except for the sephm and sepms elements). 2) The module must be written using UTF-8 characters if the language includes any non-ASCII characters. 3) Each element includes a list of values (different variations of the element). In most cases, the order of the values for each element is not important since they are just used to create a regular expression for parsing dates, but a few of them are also used to determine printable values using the Date::Manip::Date::printf method (or the UnixDate function). These elements are: Element printf directive ampm %p day_abb %a day_char %v day_name %A month_abb %b month_name %B nth %E For each of these, the value that should be printed out must be the first value in the list. 4) When possible, if a language includes characters that are essentially ASCII characters with a punctuation mark, please include a variation of the value which is just ASCII with the punctuation removed. For example, the spanish name for Saturday in ASCII would be written sabado, but in reality, the first 'a' has an accent over it. This word should appear twice... first in full UTF-8 encoding, and second as all ASCII. If the language (Russian for example) has no ASCII equivalent, just include the UTF-8 representation. Feel free to contact me if you have any questions. SEE ALSO
Date::Manip - main module documentation LICENSE
This script is free software; you can redistribute it and/or modify it under the same terms as Perl itself. AUTHOR
Sullivan Beck (sbeck@cpan.org) perl v5.14.2 2012-06-02 Date::Manip::Lang(3pm)
All times are GMT -4. The time now is 01:43 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy