Sponsored Content
Top Forums Shell Programming and Scripting Substract 1 Month from MonthID Post 302900763 by Don Cragun on Thursday 8th of May 2014 02:00:01 PM
Old 05-08-2014
Quote:
Originally Posted by pinnacle
Thanks Don Cragun !!

... ... ...

I am planning to use the 1st solution, but it I had a little concern, will this command work if unix admin apply some patch in future? Or should I be using the script that I created since it only uses very basic commands??

Appreciate your reply on this.

Also I have modified the command little bit to suit my needs as follows:
Code:
 
 
MonthID=$output; MonthID=$((MonthID - 1)); if [ $((MonthID % 100)) -eq 0 ]; then MonthID=$((MonthID - 88)); fi; printf "%d\n" "$MonthID"


Note: MonthID here will be set by output of another ETL process.

Appreciate your reply on my questions.
There shouldn't be any reason to avoid the above constructs on your current or future releases of AIX. You can also get rid of the 1st command in your script:
Code:
MonthID=$((output - 1)); if [ $((MonthID % 100)) -eq 0 ]; then MonthID=$((MonthID - 88)); fi; printf "%d\n" "$MonthID"

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Substract date (month) Problem

#!/bin/ksh month=`date | cut -c5-8` year=`date | cut -c24-28` echo "$month" echo "$year" --- This gives me output as Feb and 2009 but now I want to substract the 1 month from the current script and want output as Jan 2009. Please note I have searched a lot on forum and found... (5 Replies)
Discussion started by: niceboykunal123
5 Replies

2. UNIX for Dummies Questions & Answers

Substract a certain number to the names of several files

We have a list of files (raw and jpeg types) with 2 different extensions (rw2 and jpg). When there is both the raw and jpeg files, their file numbers must be the same (215 and 215, 218 and 218). Sometimes there is only the jpeg file (216,217). bla_215.rw2 bla_215.jpg bla_216.jpg bla_217.jpg... (9 Replies)
Discussion started by: Epictete
9 Replies

3. Shell Programming and Scripting

substract column based on some criteria

Please guide if you know how to solve this. I have a tab delimited INPUT FILE where each record is separated by ----- ----- ABC 4935402 4936680 Pattern=Cheers07080.1 ABC 4932216 4932368 Pattern=Cheers07080.1 ABC 4931932 4932122 ... (8 Replies)
Discussion started by: sam_2921
8 Replies

4. 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

5. Solaris

Substract time between two columns

I've start and end time in two columns. How can I substract time from column 2 and column 1 and receive output in another file 'd' ? $ cat c 12:55:04 2:03:56 2:03:56 3:20:17 14:00:00 13:05:00 (1 Reply)
Discussion started by: alps0206
1 Replies

6. Shell Programming and Scripting

substract variable from each line in a file

Hi everyone, I have a file containing one column and I want to subtract the first value (value of first line) from each line's value. 79304 99299 119294 139289 159284 179279 199274 219269 239264 259259 279254 299249 319244 339239 359234I tried working on an awk solution with... (1 Reply)
Discussion started by: ink_LE
1 Replies

7. Shell Programming and Scripting

Script to counting a specific word in a logfile on each day of this month, last month etc

Hello All, I am trying to come up with a shell script to count a specific word in a logfile on each day of this month, last month and the month before. I need to produce this report and email it to customer. Any ideas would be appreciated! (5 Replies)
Discussion started by: pnara2
5 Replies

8. Shell Programming and Scripting

Substract and print

Dear all, I need your help. I have file input like this: input.txt: R1031 50111G1 R1031 50121G1 R1031 50131G1 R1031 50141G1 R1031 50151G1 . . . . Desired output: 10315011 = G, 10315012 =... (2 Replies)
Discussion started by: attila
2 Replies

9. Shell Programming and Scripting

How to add decimal month to some month in sql, php, perl, bash, sh?

Hello, i`m looking for some way to add to some date an partial number of months, for example to 2015y 02m 27d + 2,54m i need to write this script in php or bash or sh or mysql or perl in normal time o unix time i`m asking or there are any simple way to add partial number of month to some... (14 Replies)
Discussion started by: bacarrdy
14 Replies

10. Shell Programming and Scripting

Need last month files after 10th of every month

Hi, I need all file names in a folder which has date >= 10th of last month, Example : files in folder AUTO_F1_20140610.TXT BUTO_F1_20140616.TXT CUTO_F1_20140603.TXT FA_AUTO_06012014.TXT LA_AUTO_06112014.TXT MA_AUTO_06212014.TXT ZA_AUTO_06232014.TXT Output: AUTO_F1_20140610.TXT... (9 Replies)
Discussion started by: nani1984
9 Replies
nl_langinfo(3int)														 nl_langinfo(3int)

Name
       nl_langinfo - language information

Syntax
       #include <nl_types.h>
       #include <langinfo.h>

       char *nl_langinfo (item)
       nl_item item;

Description
       The  function  returns a pointer to a null-terminated string containing information relevant to a particular language or cultural area. The
       language is identified by the last successful call to the appropriate category.	The categories are shown in the following  table  and  are
       defined in

       For  instance,  the following example would return a pointer to the string representing the abbreviated name for the first day of the week,
       as defined by category
       nl_langinfo (ABDAY_1);

       If the category has not been called successfully, data for a supported language is not available, or is not defined, then returns a pointer
       to an empty (null) string.  In the C locale, the return value is the American English string defined in the following table:

       -----------------------------------------------------------------------
       Identifier   Meaning			    C locale	  Category
       -----------------------------------------------------------------------
       NOSTR	    Negative response		    no		  LC_ALL
       YESSTR	    Positive response		    yes 	  LC_ALL
       D_T_FMT	    Default date and time format    %a %b %d
						    %H:%M:%S %Y   LC_TIME
       D_FMT	    Default date format 	    %m/%d/%y	  LC_TIME
       T_FMT	    Default time format 	    %h:%m:%s	  LC_TIME

       DAY_1	    Day name			    Sunday	  LC_TIME
       DAY_2	    Day name			    Monday	  LC_TIME
       ....	    ....			    ....	  ....
       DAY_7	    Day name			    Saturday	  LC_TIME

       ABDAY_1	    Abbreviated day name	    Sun 	  LC_TIME
       ABDAY_2	    Abbreviated day name	    Mon 	  LC_TIME
       ABDAY_3	    Abbreviated day name	    Tue 	  LC_TIME
       ....	    ....			    ....	  ....
       ABDAY_7	    Abbreviated day name	    Sat 	  LC_TIME

       MON_1	    Month name			    January	  LC_TIME
       MON_2	    Month name			    February	  LC_TIME
       MON_3	    Month name			    March	  LC_TIME
       ....	    ....			    ....	  ....
       MON_12	    Month name			    December	  LC_TIME

       ABMON_1	    Abbreviated month name	    Jan 	  LC_TIME
       ABMON_2	    Abbreviated month name	    Feb 	  LC_TIME
       ....	    ....			    ....	  ....
       ABMON_12     Abbreviated month name	    Dec 	  LC_TIME

       RADIXCHAR    Radix character		    .		  LC_NUMERIC
       THOUSEP	    Thousands separator 			  LC_NUMERIC
       CRNCYSTR     Currency format				  LC_MONETARY
       AM_STR	    String for AM		    AM		  LC_TIME
       PM_STR	    String for PM		    PM		  LC_TIME
       EXPL_STR     Lower case exponent character   e		  LC_NUMERIC

       EXPU_STR     Upper case exponent character   E		  LC_NUMERIC
       -----------------------------------------------------------------------

See Also
       intro(3int), ic(1int), setlocale(3int), environ(5int), nl_types(5int)
       Guide to Developing International Software

																 nl_langinfo(3int)
All times are GMT -4. The time now is 12:37 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy