Sponsored Content
Top Forums Shell Programming and Scripting How to pass current year and month in FOR LOOP in UNIX shell scripting? Post 302745615 by shoan on Monday 17th of December 2012 04:15:27 PM
Old 12-17-2012
How to pass current year and month in FOR LOOP in UNIX shell scripting?

Hi Team,

I have created a script and using FOR LOOP like this and it is working fine.

Code:
for Month in  201212 201301 201302 201303  
do

echo "Starting the statistics gathering of $Month partitions "  

done

But in my scripts the " Month " variable is hard-coded. Can you please any one help me how to capture the month variable in UNIX in this format ("YYYYMM") and pass it dynamically in the FOR LOOP.

Thanks in Advance
Shoan
 

9 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

how to get the last month and year in UNIX

how to get the last month and year in UNIx (2 Replies)
Discussion started by: Vijay06
2 Replies

2. AIX

Convert unix timestamp to year month day format ?

Hello, How do I convert unix timestamp value to 'normal' date format - to get year month and day values ? Looks like it's easy to do using GNU date (linux systems). But how do I do tthis on AIX ? I don't want to write C program, any ways to do that using unix shells ? thanks (1 Reply)
Discussion started by: vilius
1 Replies

3. UNIX for Dummies Questions & Answers

print previous month (current month minus 1) with Solaris date and ksh

Hi folks month=`date +%m`gives current month Howto print previous month (current month minus 1) with Solaris date and ksh (7 Replies)
Discussion started by: slashdotweenie
7 Replies

4. Programming

Interval year to month

Hi, I'm working on a Informix4gl module. I'm just trying to find out any built-in function to fetch only the year/month from an INTERVAL YEAR TO MONTH data value. Please let me know, if there are any functions to do this. If not, let me know for any alternative solutions to attain this. ... (5 Replies)
Discussion started by: dvah
5 Replies

5. Shell Programming and Scripting

want to get last year and month from the file

Hi I have files like abc_cd_20110302_123423 abc_cd_ef_20110301_123423 abc_cd_ef_20110403_123423 abc_ef_20110401_123423 I want to extract the the year and month associated with each file. I tried logfileyearmonth=`echo $logfile | awk -F_'{print $NF}'` Any other way can I... (6 Replies)
Discussion started by: dgmm
6 Replies

6. UNIX for Dummies Questions & Answers

Unix man command to find out month of the year?

how can i display month of the year i was born with using man command? thanks (2 Replies)
Discussion started by: janetroop95
2 Replies

7. HP-UX

Unable to pass a space inside a variable shell scripting

Can anyone help me in solving this ? p=`date` e=`echo $p | awk '{print $2,$3}'` # echo $p Wed Aug 4 12:00:08 IST 2013 but when I am echoing the value of e it is giving me with one space. As shown below: # echo $e Aug 4 I need this value to be exact as found in... (6 Replies)
Discussion started by: Kits
6 Replies

8. Shell Programming and Scripting

If else condition inside for loop of awk command in UNIX shell scripting

Hi , Please excuse me for opening a new thread i am unable to find out the syntax error in my if else condition inside for loop in awk command , my actual aim is to print formatted html td tag when if condition (True) having string as "failed", could anyone please advise what is the right... (2 Replies)
Discussion started by: karthikram
2 Replies

9. Shell Programming and Scripting

How to get the for loop output from a remote server in UNIX shell scripting?

Hi, I am using ksh , when i try to use for loop i am getting the expected output. $for variable in $(ps -fu user | grep -i something/ | grep -i something | grep -v grep | awk '{print $2}');do > grep $variable /tmp/some_path/*/* > done when tried the below to remote server, getting... (4 Replies)
Discussion started by: karthikram
4 Replies
calendar(1)						      General Commands Manual						       calendar(1)

NAME
calendar - reminder service SYNOPSIS
DESCRIPTION
consults the file in the current directory and prints out lines containing today's or tomorrow's date anywhere in the line. On weekends, ``tomorrow'' extends through Monday. When a command-line argument is present, searches for the file in each user's home directory, and sends any positive results to the user by (see mail(1)). Normally this is done daily in the early morning hours under the control of (see cron(1M)). When invoked by reads the first line in the file to determine the user's environment. Language-dependent information such as spelling and date format (described below) are determined by the user-specified statement in the file. This statement should be of the form where language is a valid language name (see lang(5)). If this line is not in the file, the action described in the section is taken. is concerned with two fields: month and day. A month field can be expressed in three different formats: a string representing the name of the month (either fully spelled out or abbreviated), a numeric month, or an asterisk (representing any month). If the month is expressed as a string representing the name of the month, the first character can be either upper-case or lower-case; other characters must be lower- case. The spelling of a month name should match the string returned by calling (see nl_langinfo(3C)). The day field is a numeric value for the day of the month. Month-Day Formats If the month field is a string, it can be followed by zero or more blanks. If the month field is numeric, it must be followed by either a slash or a hyphen If the month field is an asterisk it must be followed by a slash The day field can be followed immediately by a blank or non-digit character. Day-Month Formats The day field is expressed as a numeral. What follows the day field is determined by the format of the month. If the month field is a string, the day field must be followed by zero or one dot followed by zero or more blanks. If the month field is a numeral, the day field must be followed by either a slash or a hyphen If the month field is an asterisk, the day field must be followed by a slash EXTERNAL INFLUENCES
Environment Variables determines the format and contents of date and time strings when no statement is specified in the file. determines the language in which messages are displayed. If is not specified in the environment or is set to the empty string, the value of is used as a default for each unspecified or empty vari- able. If is not specified or is set to the empty string, a default of "C" (see lang(5)) is used instead of If any internationalization variable contains an invalid setting, behaves as if all internationalization variables are set to "C". See environ(5). International Code Set Support Single- and multi-byte character code sets are supported. EXAMPLES
The following file illustrates several formats recognized by calendar: In the following file, dates are expressed according to European English usage: WARNINGS
To get reminder service, either your calendar must be public information or you must run from your personal file, independent of any run systemwide. Note that if you run yourself, the calendar file need not reside in your home directory. extended idea of ``tomorrow'' does not account for holidays. This command is likely to be withdrawn from X/Open standards. Applications using this command might not be portable to other vendors' platforms. AUTHOR
was developed by AT&T and HP. FILES
to figure out today's and tomorrow's dates SEE ALSO cron(1M), nl_langinfo(3C), mail(1), environ(5). STANDARDS CONFORMANCE
calendar(1)
All times are GMT -4. The time now is 06:10 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy