![]() |
|
|
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 |
| What the command to find out the record length of a fixed length file? | tranq01 | UNIX for Dummies Questions & Answers | 9 | 12-04-2008 04:04 PM |
| print a file with one column having fixed character length | smriti_shridhar | Shell Programming and Scripting | 2 | 10-03-2008 09:02 AM |
| sed replace with fixed length | McLan | Shell Programming and Scripting | 7 | 05-15-2008 03:57 AM |
| Fixed length (Fill out) | peterk | Shell Programming and Scripting | 3 | 09-28-2007 12:04 PM |
| creating a fixed length output from a variable length input | r1500 | Shell Programming and Scripting | 2 | 12-03-2003 01:09 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
How to print string on screen according the fixed length?
Problem:
entry_name="joke:hello:yellow:blue:default" print("%d %-12s\t%-10s\t%-5s\n", $i, $entry_name....); I just want to print the output like this index entry value .... 1 joke:hello:y 0 123 567 ellow:blue:d efault My step: get the length of the entry_name i=0 entry_length=$(echo "$entry_name" | awk '{print length($entry_name)}') ((j=entry_length/12)) while((i<j)) do tmp=$(echo "$entry_name" | awk '{print substring($entry_name, i*12, 12)}') printf("%-12s\n", tmp); ((i=i+1)) done |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|