I keep getting bitten over and over again with newline issues.
My first issue is, I have a string in bash where I'm appending "\n" via the echo -e command, because I want each result to be on it's own line, as I'm going to output that string eventually to file. When I echo the string out, it looks correct. If I grep through it trying to find one line,
var=$(echo $var2 | grep pattern)
I discover that it sees the string as one line. I don't want that. How do I change that so grep would work as expected, matching the lines of interest (question 1).
Also, if you have any insights on the following, seemingly related, I'd appreciate it: when I do a find on the command line, it separates results by (apparently) newlines. Assigning the results of find to a bash variable and then grepping or searching through that, it appears the find results are all one line. I've tried/researched some of the
find -print
options but haven't been successful, perhaps it is a similar problem to number 1. I'm not getting something here. The second question would be, what's the right option to use on a find command so when I assign it to a variable and grep through the results, it works like it would on the command line (meaning find | grep).
Thanks.