The UNIX and Linux Forums  

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 3 02-06-2007 11:02 PM
AWK and padding values kshelluser UNIX for Dummies Questions & Answers 3 11-29-2006 02:14 PM
Padding variables flounder High Level Programming 1 09-05-2006 09:11 AM
text formating/Text space padding hugow UNIX for Dummies Questions & Answers 6 06-29-2005 06:49 AM
Padding vijaygopalsk UNIX for Dummies Questions & Answers 2 06-27-2003 07:51 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 01-08-2008
Registered User
 

Join Date: May 2006
Posts: 25
Exclamation Quick help on space padding

Hi all,

I need to create a header record of width 121 charecter with below fields,
position 001-001 - 0
position 002-15 - filled with space
position 016-020 - date value
position 021-121 - filled with space

Iam using the below code:

echo 0"14 spaces"$date"100 spaces" >> output.txt

But I dont think this is correct approach. Could any one please correct me if Iam wrong?

With Regards / Lokesha R
Reply With Quote
Forum Sponsor
  #2  
Old 01-08-2008
Registered User
 

Join Date: Sep 2006
Posts: 1,580
check the printf command
eg
Code:
# printf "%05d" 13
00013
Reply With Quote
  #3  
Old 01-08-2008
Registered User
 

Join Date: Dec 2007
Posts: 258
printf should do it

Code:
printf "%-15d%5s%100s\n" 0 "$date_here"
Reply With Quote
  #4  
Old 01-08-2008
ganapati's Avatar
Registered User
 

Join Date: Jul 2006
Posts: 114
Thanks to all for the needful answers.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 05:06 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0