[Novalug] Indented word-wrapped echoing from a makefile

Jon LaBadie novalugml@jgcomp.com
Thu Dec 13 10:01:45 EST 2012


On Thu, Dec 13, 2012 at 01:51:59PM +0000, sean@mcgowanet.com wrote:
> Try piping your command to a sed -e 's/^/     /'.
> 
> Sent via BlackBerry by AT&T
> 
> -----Original Message-----
> From: Michael Henry <lug-user@drmikehenry.com>
> Sender: novalug-bounces@calypso.tux.org
> Date: Thu, 13 Dec 2012 08:33:36 
> To: novalug<novalug@calypso.tux.org>
> Subject: [Novalug] Indented word-wrapped echoing from a makefile
> 
> All,
> 
> I'm looking for an elegant way to wrap echoed text in a
> makefile.  Consider the following makefile (``wrap.mk``)::
> 
>   LIST=some list of words like filenames
> 
>   all:
>           @echo LIST=$(LIST) | fmt -w 1
> 
> The output of ``make -f wrap.mk`` is::
> 
>   $ make -f wrap.mk
>   LIST=some
>   list
>   of
>   words
>   like
>   filenames
> 
> I'd like each word in LIST to be on its own line, indented, like
> this::
> 
>   LIST=
>     some
>     list
>     of
>     words
>     like
>     filenames
> 


No need for fmt, sed or awk could do it.

@echo LIST=$(LIST) | sed -e 's/ /\n  /g' -e 's/=/=\n  /'

Note, I think some sed's may not allow the use of '\n'.

jl
-- 
Jon H. LaBadie                  novalugml@jgcomp.com
 11226 South Shore Rd		(703) 787-0688 (H)
 Reston, VA  20190		(609) 477-8330 (C)



More information about the Novalug mailing list