converting day to capital letter...

Hello,

I am receiving a file every day as this format. Since today is friday, the format is, PGI_STG_FRIDAY14.TXT.

I need to write the shell script to check if this file exist in folder...

I am using date format..

export DATE=`date '+%A'`
echo $DATE

The output is Friday

But i want to covert this to capital leters FRIDAY

How can i do this? Any help is greatly appreciated...

export DATE=`date '+%A'`
echo $DATE | tr '[:lower:]' '[:upper:]'

Excellent !!!

Hello, I need your help here. I have two questions.

Question 1
I recevied the IP2_PGI_NOVEMBER13.TXT file in unix. I wanted to check if this file exists and if so then i need to load this file into oracle table.

export EXT='.TXT'
export I2PFILE='I2P_PGI_'
export DATE=`date '+%B%d`
echo $I2PFILE$DATE$EXT | tr '[:lower:]' '[:upper:]'

The above script gives the file name as I2P_PGI_NOVEMBER14.TXT

But i want to store in variable. How can i store this in one variable...

export $I2PFILE$DATE$EXT | tr '[:lower:]' '[:upper:]' is not working....

Question 2

I always receive previous day file. So today is nov 14th. But i receive I2P_PGI_NOVEMBER_13.TXT file. How can i deduct one day from DATE command...

Your help is highly appreciated....

export EXT='.TXT'
export I2PFILE='I2P_PGI_'
export DATE=`date '+%B%d' --date="1 days ago"`
MYVAR=`echo $I2PFILE$DATE$EXT | tr '[:lower:]' '[:upper:]'`

echo $MYVAR

First print today's date:
$ date
Sun Jun 17 12:17:24 CDT 2007

Now display Yesterday's date:
$ date --date="1 days ago"
OR try:
$ date --date="yesterday"
Sat Jun 16 12:17:20 CDT 2007

Now display Tomorrow's date:
$ date --date="-1 days ago"

Or better try:
$ date --date="next day"
$ date --date='2 year ago' # past
$ date --date='3 years' # go into future
$ date --date='2 days' # future
$ date --date='1 month ago' # past
$ date --date='2 months' # future
$ date --date='this Friday'
$ date --date='2 months ago 5 day ago'

NOTICE: These will NOT work on HP-UX!!!

Great. it is working... But still date -1 part is not working.. I am trying different option.

Here is the error message...

==> sh test.sh
Invalid character in date/time specification.
Usage: date [-u] [+Field Descriptors]
I2P_PGI_.TXT

Hello, My unix machine is AIX. The date logic is not working... Any thoughts...

==> uname
AIX
paixdb02(supprd) /home/odsapp
==> date --date="1 days ago"
date: illegal option -- -
Usage: date [-u] [+Field Descriptors]
paixdb02(supprd) /home/odsapp
==>

I dont know about AIX but, On my HP-UX I had to do the following:

OFFSET=${1:-1}

case $OFFSET in
  *[!0-9]* | ???* | 3? | 29) print -u2 "Invalid input" ; exit 1;;
esac

eval `date "+day=%d; month=%m; year=%Y`
typeset -Z2 day month
typeset -Z4 year

day=$((day - OFFSET))
if (( day <= 0 )) ;then
  month=$((month - 1))
  if (( month == 0 )) ;then
    year=$((year - 1))
    month=12
  fi
  set -A days `cal $month $year`
  xday=${days[$(( ${#days[*]}-1 ))]}
  day=$((xday + day))
fi

echo $day

Thanks again. I used this code to find the previous day. I found this in this forum. Thanks for all your help today. Appreciated...

date '+%m %d %Y' | 
{ 
read MONTH DAY YEAR
DAY=`expr "$DAY" - 1` 
case "$DAY" in 
        0) 
           MONTH=`expr "$MONTH" - 1` 
                case "$MONTH" in 
                        0) 
                           MONTH=12 
                           YEAR=`expr "$YEAR" - 1` 
                        ;; 
                esac 
        DAY=`cal $MONTH $YEAR | grep . | fmt -1 | tail -1` 
esac 
echo "Yesterday was: $MONTH $DAY $YEAR" 
}