![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Development Releases: Linux Mint 4.0 Beta "Fluxbox", 4.0 Alpha "Debian" | iBot | UNIX and Linux RSS News | 0 | 01-04-2008 03:00 PM |
| Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`" | Lokesha | UNIX for Dummies Questions & Answers | 4 | 12-20-2007 01:52 AM |
| how could i make a program mixed with many "|", "<" and ">" | strugglingman | High Level Programming | 2 | 04-29-2006 09:11 AM |
| No utpmx entry: you must exec "login" from lowest level "shell" | peterpan | UNIX for Dummies Questions & Answers | 0 | 01-18-2006 04:15 AM |
| how to request a "read" or "delivered" receipt for mails | plelie2 | Shell Programming and Scripting | 1 | 08-06-2002 04:26 PM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
need to keep the "0" in "01"
System = AIX
scripting = ksh me = fairly new to this. I hope this has not been asked already. Scenario: grep'ing for information out of files with a naming convention as such.... 2008_01*. I will be performing my grep on these file names during the month after (i.e. 02). Problem: When I try to subtract "02" - "01", get "1". This makes sense seeing as how most calculations drop the preceding "0" I need to keep that "0" to perform my grep. Code: # ======> GET YEAR & MONTH *** #export YEAR=`date +%Y` #export MNTH=`date +%m` export YEAR=2008 export MNTH=02 # ************************************** # *** FIND PREVIOUS MONTH/YEAR VALUE *** # ************************************** if [ $MNTH!=01 ] then (( MNTH=$MNTH-01 )) YEAR=$YEAR else if [ $MNTH=01 ] then MNTH=12 (( YEAR=$YEAR-1 )) fi fi ***NOTE ~ (( YEAR=$YEAR-1 )) works perfectly. !!!!!The above statement is now incorrect!!!!! I would prefer to keep it as simple as it is now, however all help is appreciated. I would consider using sed or awk to add the "0" in, however an example or two of how to do that would be great. Last edited by cml2008; 01-26-2008 at 12:15 AM.. Reason: statement is now incorrect |
| Bookmarks |
| Tags |
| linux |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|