Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
Assign to a Variable
Name: Nish Date: December 30, 2002 at 00:06:59 Pacific OS: Solaris CPU/Ram: 256
Comment:
I need to calculate the Yesterday's date and received a good code from Unix forum. I need to assign the yesterdays Date (MONTH and DATE eg. 1229 for Dec 29)to a Variable ,say myvar. $myvar can be used in any where of the program after that !
#!/bin/ksh GetDate () { set -A DAYS Sat Sun Mon Tue Wed Thu Fri Sat set -A MONTHS Dec Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec YESTERDAY=$((`date +%d` -1)) MONTH=`date +%m` YEAR=`date +%Y` NDAY=`date +%u` WEEKDAY=${DAYS[`date +%u`]} if [ $YESTERDAY -eq "0" ] then MONTH=$((MONTH-1)) if [ $MONTH -eq "0" ] then MONTH=12 YEAR=$((YEAR-1)) fi
set `cal $MONTH $YEAR` shift $(($# - 1)) YESTERDAY=$1 fi TMONTH=${MONTHS[MONTH]} $YEAR echo $MONTH$YESTERDAY return 0 }
Summary: Is it possible to use a shell script to login to a database (using Teradata), run a query and assign the query result to a local variable defined in the shell? I know it's possible to run teradata SQL...
Summary: Hi, i have grepped a process number from a file & redirected to temp file. from temp file, I should assign process number to a variable "pnum". to execute a script Select statistics pnumber= summary=...
Summary: Dear All, My OS : Solaris and Shell is ksh. I have a requirement to assign date to a variable. I tried following and failed. myvar=date '+ %y%m%d_%h' After that I need to do an awk fo all the files co...