help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] play audio-CD in consol


From: Eric Blake
Subject: Re: [Help-bash] play audio-CD in consol
Date: Wed, 30 Jan 2013 10:48:49 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2

On 01/30/2013 10:42 AM, Gerard ROBIN wrote:

> I would like to know if to display the 3 following lines:
> 
>           foo bar base
>           foo bar base foo bar baz
>           foo bar base foo bar baz foo bar base
> 
> it is the appropriate way to write:
> 
> line1="foo bar base"
> line2="foo bar base foo bar baz"
> line3="foo bar base foo bar baz foo bar base"
> 
> printf "%$((${#line1}+10))s\n%$((${#line2}+10))s\n%$((${#line3}+10))s\n" 
> "$line1" "$line2" "$line3"
> 
> If yes, printf is hard to read (and write) too. If not, how can we write
> this most simply ? ( with printf )

Restating the problem, given line1, 2, and 3 with no leading space, you
want to print each of them with 10 space indentation?  Simple:

printf "          %s\n" "$line1" "$line2" "$line3"

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]