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:
cata filefindsome directories- Concatenate the results
- Feed them as here-document to the
whileloop
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 ofcatand the output ofecho. Soleechoprints 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. :) – Kamil Maciorowski Feb 24 '23 at 13:13