Issue
I am using the combination of the ls + sed to make a list of the images in the folder and create output file of scpeficic format where each line separated by the empty line etc
ls ${blocks}/*png | sed 's/^/\n/' > ${blocks}/out
The problem is that, inspite of the \n in the end sed does not add a "new line" after each string.
also would it be better to use find instead of ls for big number of png images?
Solution
Parsing output of ls
can be error prone and must be avoided. Moreover bsd sed
doesn't interpret \n
as newline like you're using and emits a literal n
in the substitution.
However, you don't even need ls | sed
here, just use this for loop:
for f in "$blocks"/*.png; do
printf '\n\n' "$f"
done > "$blocks"/out
Or better just printf
:
printf '\n\n' "$blocks"/*.png
Answered By - anubhava Answer Checked By - Terry (WPSolving Volunteer)