help-bash
[Top][All Lists]
Advanced

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

Printing with and without newlines


From: irenezerafa
Subject: Printing with and without newlines
Date: Sat, 13 Nov 2021 22:09:46 +0000

> > nl=$'\n'

> > notice the $
>
> Thanks. Have done as follows
>
> nl=3
> printf '%s\n' "nwline: $nwline"
> (( nwline == 1 )) && fs=$'\n' || fs=$' '
> printf '%s%s' "${ctp}${@:1:nl}${rst}" "$fs"

> But still the first three arguments get displayed on a single line

> pfm "Mary" "had" "a" "little" "lamb"
> nwline: 1
> Maryhada

To continue, I tried declaring an array and changing IFS in a subshell

nwline=1 ; aggr=("$@")
(( nwline == 1 )) && fsb='\n' || fsb=' '
( IFS=$fsb ; echo "${aggr[*]}" )

But the above still wrote on the same line





reply via email to

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