The problem
I have multiple property lines in a single string separated by \n
like this:
LINES2="Abc1.def=$SOME_VAR\nAbc2.def=SOMETHING_ELSE\n"$LINES
The LINES
variable
- might contain an undefined set of characters
- may be empty. If it is empty, I want to avoid the trailing
\n
.
I am open for any command line utility (sed, tr, awk, ... you name it).
Tryings
I tried this to no avail
sed -z 's/\\n$//g' <<< $LINES2
I also had no luck with tr, since it does not accept regex.
Idea
There might be an approach to convert the \n
to something else. But since $LINES
can contain arbitrary characters, this might be dangerous.
Sources
I skim read through the following questions