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

Re: awk not just using the Field separator as such. it is using the blank space as well ...



On Wed, 15 Feb 2023 at 18:22, DdB
<debianlist@potentially-spam.de-bruyn.de> wrote:
> Am 15.02.2023 um 07:25 schrieb Albretch Mueller:

> > $ _L="Adams, Fred, and Ken Aizawa \"The Bounds of Cognition\""
> > echo "// __ \$_L: |${_L}|"
> > _AR=($(echo "${_L}" | awk -F'\"' '{for (i=1; i<=NF; i++) print $i}' ))
> > _AR_L=${#_AR[@]}
> > echo "// __ \$_AR_L: |${_AR_L}|"
> > for(( _IX=0; _IX<${_AR_L}; _IX++ )); do
> >  echo "// __ [$_IX/$_AR_L): |${_AR[$_IX]}|"
> > done

> what awk are you using? gnu awk works fine. see:

The complaint has nothing to do with awk.

The reason this is happening is because when the
shell creates the elements of the array _AR, it
parses those elements as separated by any whitespace.

Whereas the OP expects the elements to be
separated by newlines.

Just looking at this made my eyes bleed so that,
combined with the total lack of troubleshooting
effort, means that my answer ends as follows:

Start reading here:
  http://mywiki.wooledge.org/BashFAQ/005


Reply to: