![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
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 |
| addition in sh shell | cfg | UNIX for Dummies Questions & Answers | 1 | 09-28-2008 03:53 PM |
| Simple addition, help. | Bandit390 | Shell Programming and Scripting | 3 | 09-23-2008 02:46 PM |
| addition | email-lalit | Shell Programming and Scripting | 2 | 08-06-2008 05:58 PM |
| Addition problem | onlyroshni | Shell Programming and Scripting | 2 | 12-10-2007 02:11 PM |
| floating point addition | ravi raj kumar | Shell Programming and Scripting | 8 | 12-22-2006 02:47 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|||||
|
help in date script
below my script . Actually in my script i m taking the current date and then adding 15 days to it.
-------------------------------------------------------------------------- #!/bin/ksh Current_day=`perl -e 'print int(time);'` echo $Current_day count=0 count=`expr $Current_day + 1296000` echo $count perl -le 'print scalar localtime('"$count"');' perl -e '@d=localtime ((stat(shift))[9]); printf "%4d-%02d-%02d\n", $d[5]+1900,$d[4]+1,$d[3]' '"$count"' -------------------------------------------------------------------------- the last command that converts the $count value into format YYYY-MM-DD is not working . plz help me in this? |
|
||||
|
Code:
#!/bin/ksh
tictock()
{
perl -e '
$now = time;
$increment = 1296000;
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($now);
$year += 1900;
for($i=0, $thisyear = $year ; $thisyear==$year ; $i++)
{
printf ("%4d-%02d-%02d ", $year, $mon, $mday);
$incr=($increment * $i) + $now;
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime($incr);
$year += 1900;
$mon += 1;
}
'
}
set -A arr $(tictock )
let i=0
while [[ $i -lt ${#arr[*]} ]]
do
print ${arr[i]}
i=$(( i + 1))
done
|
|
|||||
|
Quote:
|
| Sponsored Links | ||
|
![]() |
| Bookmarks |
| Tags |
| perl, perl shift, shift, shift perl |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|