I have this script:
while read $item;
do
# Some bash logic here
done <<< "$({ cat /path/to/some/file; echo; })"
Now I want to also use find
to find the name of some directories, and pass that alongside the cat
to the while
loop.
In other words, I want to:
cat
a filefind
some directories- Concatenate the results
- Feed them as here-document to the
while
loop
I'm stuck at this point.
I though of duplicating the while
logic, which is not a good method. I also thought of reusing the logic inside the while
loop using functions.
However, concatenating stuff in here-document might seem to be the correct way to do it.
<<< "$(…)"
aside, a note: you already concatenate the output ofcat
and the output ofecho
. Soleecho
prints a newline and it's futile here because$()
removes all trailing newlines (and then<<<
adds exactly one). My point is you already concatenate the results of two commands. :)