The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

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 07:09 PM
trimming zeros mohan705 UNIX for Advanced & Expert Users 3 03-23-2008 10:38 AM
Pad zeros to a number anumkoshy Shell Programming and Scripting 6 08-27-2007 05:13 AM
Leading zeros wtofu Shell Programming and Scripting 1 09-16-2006 02:52 PM
remove precursing zeros gozer13 Shell Programming and Scripting 2 08-10-2005 06:42 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-10-2007
mgirinath mgirinath is offline
Registered User
  
 

Join Date: May 2005
Posts: 69
pad Zeros

Hi can I know command to pad Zeros to a value
Code:
I get 16 and I need to send 0000000016
  #2 (permalink)  
Old 04-10-2007
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,522
Code:
printf "%08d" 16
  #3 (permalink)  
Old 04-10-2007
mgirinath mgirinath is offline
Registered User
  
 

Join Date: May 2005
Posts: 69
sorry I should have specified it more clear...

I may also get numbers like this...
Code:
16
116
1116

all these should be populated with leading zero's and length equal to 8
00000016
00000116
00001116
....
  #4 (permalink)  
Old 04-10-2007
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,952
Code:
a=16
typeset -Z 8 a
echo $a
  #5 (permalink)  
Old 04-10-2007
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,522
Then it should be this:
Code:
printf "%0.8d" 1116
or if you prefer awk
Code:
awk 'BEGIN {printf("%0.8d\n", 1116)}'
  #6 (permalink)  
Old 04-10-2007
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,952
Quote:
printf "%0.8d" 1116
should be

Code:
printf "%0.8d\n" 1116
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:03 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0