![]() |
|
|
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 |
| Padding with zeros. | sbasetty | Shell Programming and Scripting | 10 | 05-18-2009 08:09 PM |
| Help needed in padding leading zeros | jakSun8 | Shell Programming and Scripting | 12 | 07-02-2008 08:41 PM |
| Help with typeset in bash | Ian_H | Shell Programming and Scripting | 5 | 09-19-2007 11:04 AM |
| typeset -f ??? | xinfinity | Shell Programming and Scripting | 1 | 04-04-2006 05:43 PM |
| Padding zeros after removing commas in file | pranag21 | HP-UX | 1 | 11-09-2005 10:22 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Hi everybody,
I have a question about typesetting. I originally wrote a script for use with ksh and now I am on a system that I cannot modify, and it only has bash. In the original script I just did typeset -RZ4 variable and it would add the leading zeros. In bash, it doesn't work. I've looked all over and I can't find anything useful that will help me format the variable. the script is just a simple script to expire about a thousand tapes from netbackup's media database. It's very tedious to do it one at a time with the tapes being labeled NB0000 - NB0999. so the variable I am typesetting will always be 4 digits. Any help would be appreciated. here is the code. it was my first attempt at shell scripting so don't make fun of it too much. #! /bin/ksh # Script to expire tapes in NBU # REQUIRES that NBU to be installed (DUH) # Tapes should be in order (ie. NR0000, NR0001, NR0002, etc) # This ensures that our format will be preserved. # Makes sure $addon has four digits. typeset -RZ4 addon # Get two letter prefix for tapes clear echo "Please enter the 2 letter prefix (ie. NR, AB, CD)" read prefix # Get the four digits of the first tape echo "Please enter the last 4 digits of the first tape (ie. 0000 0001 00002)" read addon # Get the four digits of the last tape echo "Please enter the last 4 digits of the last tape to expire" read last #Increment the last variable by one so that the while loop will work let last++ # This creates our tape name (ie NR0000 newfix=$prefix$addon # While loop to increment through the tapes while (( $addon < $last)) do /usr/openv/netbackup/bin/admincmd/bpexpdate -d 0 -m $newfix -force let addon++ newfix=$prefix$addon done echo " " echo " " echo "By the power of Grey Skull, the tapes have expired!" exit 0 Last edited by jwheeler; 07-08-2008 at 01:43 PM.. Reason: adding code. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|