tags:

views:

28

answers:

2

hi all

I have example of the follwoing lines from print command (from ksh script)

 first_name=raimondelita  last_name=plotanmkitus  Number_id=3574553442
 first_name=timratcel  last_name=plotiniues  Number_id=43
 first_name=tom  last_name=kot  Number_id=564

how to print the lines (up) like this (down) with printf

first_name=raimondelita  last_name=plotanmkitus  Number_id=3574553442
first_name=timratcel     last_name=plotiniues    Number_id=43
first_name=tom           last_name=kot           Number_id=564

THX for help Yael

A: 

use following code to align to 20 chars:

printf("%20s", str);

In your case it'll probably be more like

printf("first_name=%15s last_name=%15s Number_id=%10s\n",
        first_name, last_name, Number_id);
jdehaan
sorry but I need example for ksh not C THX
yael
unfortunately I mostly use BASH, the Korn shell is something I cannot help with, sorry.
jdehaan
A: 

Since you don't show your code, it's hard to guess in what form you have your data and how you're handling it. However, jdehaan's answer will work for ksh with slight modification. You will need to modify it further to suit your needs.

printf "first_name=%-15s last_name=%-15s Number_id=%10s\n" $first_name $last_name $Number_id
Dennis Williamson

related questions