There's an input file(input.txt) which has the following details :
CBA
BA
<Please note the second record has a LEADING WHITESPACE which is VALID>
I am using the following code to read the content of the said file line by line:
while read p ; do
echo "$p"
done < input.txt
This is the output I am getting :
CBA
BA
Note : The leading WHITESPACE in the second record is getting removed automatically when the read command
is retrieving the values and assigning it to the variable "p"
HOW CAN I RETAIN THE LEADING WHITESPACE OF A COMMAND OUTPUT ????
IS IT A DEFAULT FEATURE OF UNIX TO REMOVE ALL LEADING/TRAILING WHITESPACE CHARACTERS WHENEVER A COMMAND ASSIGNS ITS OUTPUT TO A VARIABLE
FROM THE STDOUT ??
HOW TO BYPASS IT ??
This same thing happens for the following command also :
for p in `cat input.txt` ; do
echo "$p"
done
PLEASE HELP.
Thanks
Kumarjit.