Search Results

Search: Posts Made By: anupom2000
3,548
Posted By Franklin52
MTS=$(awk -v m=$MONTHEND 'BEGIN{printf(...
MTS=$(awk -v m=$MONTHEND 'BEGIN{printf( "%.2i\n",index(" JanFebMarAprMayJunJulAugSepOctNovDec", m )/3 )}')

The index() function returns the index of m (the given month) in the string of the 1st...
3,548
Posted By alister
Alternatively, a case...esac sh statement can be...
Alternatively, a case...esac sh statement can be used. No real need to bother with external tools such as sed, awk, et al.

case $MONTHEND in
Jan) MTS=01;;
Feb) MTS=02;;
Mar)...
3,548
Posted By Franklin52
Instead of 12 sed commands: MTS=$(awk -v...
Instead of 12 sed commands:
MTS=$(awk -v m=$MONTHEND 'BEGIN{printf( "%.2i\n",index(" JanFebMarAprMayJunJulAugSepOctNovDec", m )/3 )}')
3,548
Posted By rn_
That's because you are using the $MONTHEND var in...
That's because you are using the $MONTHEND var in each assignment. The last one always gets assigned to MTS. You should change the $MONTHEND to $MTS and start with assigning $MONTHEND to MTS (ie. 1st...
Showing results 1 to 4 of 4

 
All times are GMT -4. The time now is 08:09 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy