![]() |
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 |
| Keeping your SSH connections alive with autossh | iBot | UNIX and Linux RSS News | 0 | 05-16-2008 11:20 AM |
| deleting a line but keeping the same file | laiko | UNIX for Dummies Questions & Answers | 2 | 05-13-2008 02:08 PM |
| house keeping script | Rakesh Bhat | UNIX for Dummies Questions & Answers | 7 | 01-03-2006 01:51 AM |
| keeping history of command | legato | SUN Solaris | 3 | 11-04-2004 08:41 PM |
| Keeping an eye on all user activities | shauche | UNIX for Advanced & Expert Users | 5 | 05-19-2003 06:07 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Here's one that might help:
xstart=`date '+%j'` xend=`expr $xstart - 30` while [ $xstart -gt $xend ] ; do if [ $xstart -lt 10 ]; then echo 00"$xstart" elif [ $xstart -lt 100 ]; then echo 0"$xstart" else echo $xstart fi xstart=`expr $xstart - 1` done It's not the prettiest, but it does the trick. |
|
|||||
|
Bash does not support that option to typeset.
Also, if you're using a Linux-based OS, you most likely have PDKSH installed, instead of ksh. Most versions of pdksh do not support that either - only the "real" ksh can be trusted... Good news though! You can get David Korn's KSH 93 from here: http://www.research.att.com/sw/download/ Using AT&T's package is a bit of a pain, but it's worth it. |
|
||||
|
If you cannot use typeset, you can format it with awk:
Code:
#!/bin/sh
xstart=`date '+%j'`
xend=`expr $xstart - 30`
while [ $xstart -gt $xend ] ; do
xname=`awk 'BEGIN {printf "%3.3d",'$xstart';exit}'`
echo $xname
xstart=`expr $xstart - 1`
done
|
![]() |
| Bookmarks |
| Tags |
| linux |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|