Sujet : Re: Using << and an output pipe together in shell (bash)
De : janis_papanagnou+ng (at) *nospam* hotmail.com (Janis Papanagnou)
Groupes : comp.unix.shellDate : 04. Nov 2024, 00:49:14
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vg925r$jcoe$1@dont-email.me>
References : 1 2
User-Agent : Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0
On 03.11.2024 21:37, Helmut Waitzmann wrote:
gazelle@shell.xmission.com (Kenny McCormack):
>
I just want to know if the basic syntax is valid and/or if there is a
better workaround (better than switching to: > >(...))
Either use a backslash for unfolding a folded line (as Ben
showed) or put the part of the command line following the pipe
symbol ("|") after the EOF of the here document (as Janis showed)
or embrace the simple command and its here document by "{ ... ;
}":
{
someCommand -x -y "sjdfhk" and more options \
-g and still more options -Q "another option" << EOF
some data
for someCommand
EOF
} |
/usr/lib/ANotherCommand -x "with option" and "more options"
In this vein (i.e. structuring the code) another option is to put
all these long commands with all their options into functions, so
that the complex command calls fit (with the pipes, and without
escapes) on a single line
f_someCommand <<EOF | f_anotherCommand
...
EOF
(This could make the code also better readable and maintainable.)
Janis