A simple yet annoying thing:
Using a script like this:
while read x; do
echo "$x"
done<file
on a file containing whitespace:
text
will give me an output without the whitespace:
text
The problem is i need this space before text (it's one tab mostly but not always).
So the question is: how to obtain identical lines as are in input file in such a script?
Update: Ok, so I changed my while read x
to while IFS= read x
.
echo "$x"
gives me correct answer without stripping first tab, but, eval "echo $x"
strips this tab.
What should I do then?
read
is stripping the whitespace. Wipe $IFS
first.
while IFS= read x
do
echo "$x"
done < file
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With