help-bash
[Top][All Lists]
Advanced

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

Re: printf '%s\n' "$@" versus <<< redirection


From: goncholden
Subject: Re: printf '%s\n' "$@" versus <<< redirection
Date: Mon, 20 Feb 2023 12:31:11 +0000

------- Original Message -------
On Monday, February 20th, 2023 at 1:51 AM, Greg Wooledge <greg@wooledge.org> 
wrote:


> On Sun, Feb 19, 2023 at 10:00:17AM +0000, goncholden wrote:
> 
> > theone()
> > (
> > for arg in "$@"
> > do
> > while IFS= read -r vl
> > do
> > printf '## vl: %s ##\n' "$vl"
> > done <<< "$arg"
> > done
> > )

Does the problem of disappearing variables exist in
calls to awk ? 

for arg in "$@"; do
  printf '%s\n' "$arg" | awk '...'
done

or should one use 

for arg in "$@"; do
  awk '...' < <(printf '%s\n' "$arg")
done

There is also the possibility of putting the awk command in the process 
substitution, not the printf command: 

for arg in "$@"; do
  while read ...; do
    ...
  done < <(awk '...' <<< "$arg")
done





reply via email to

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