views:

118

answers:

1

Hey,

I would like to know if its possible to do formatting using echo in shell scripting.

Here is a small code snippet which is giving me the problem

echo -en "\rFileName    :   $filename   :    $index of $lines Completed"

The Filename's is a string with varying length and this is causing problem with formating in the terminal. How can i overcome this

FileName : a800_102 : 6 of 6 Completed

FileName : ersf_1024 : 56 of 56 Completed

I would like to have a table format when I display it on the terminal. I hope, I am able to communicate my query.

Thanks in advance

Kiran

+6  A: 

Use printf:

printf "\rFileName : %20s : %8d of %8d Completed" $filename $index $lines
rq
Thanks a ton,Kiran
Kiran