Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google site



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Closed Thread
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-03-2009
Registered User
 

Join Date: Apr 2009
Location: bangalore
Posts: 35
getting the data in some format

HI i am writing a shell script to generate some files having data in some format.
for this i am using
awk -F":" '{printf("%-20s:%-20s:%-20s:%-20s:%-15s:%-3s:%-19s:%-2s:%-20s:%-15s:%-2s\n", $1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11)}' $DIALPBIN/temp1.txt > ${DIALPBIN}/temp2.txt


this helps in generating the data in correct format. but if some fields are greater than the mentioned field lenght. it doesn't truncate the data. instead the whole data ia written and goes beyond the depicted length.

could you please help so that the data do not go beyond the mentioned length and automatically gets truncated
Sponsored Links
  #2 (permalink)  
Old 08-03-2009
Registered User
 

Join Date: Jun 2009
Posts: 56

Code:
jb>printf "%-5s\n" "12345678"
12345678
jb>printf "%-5.5s\n" "12345678"
12345
jb>

Sponsored Links
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 Off


More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Help me to format this data please glev2005 UNIX for Dummies Questions & Answers 11 04-17-2009 02:20 PM
Please help me format this data glev2005 UNIX for Dummies Questions & Answers 4 11-24-2008 06:34 PM
converting a tabular format data to comma seperated data in KSH Hemamalini UNIX for Dummies Questions & Answers 2 06-16-2008 05:37 AM
data format from (4.56 0.7) -> 4.6(7) awk?! ahan Shell Programming and Scripting 4 05-07-2006 09:53 PM
format data inquirer Shell Programming and Scripting 2 09-24-2003 07:59 AM



All times are GMT -4. The time now is 04:50 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-2010. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0