I have a text file which contains the following lines:
7.3.0
12
I am using the below lines to read the content line by line
while read -r LINE; do
if test $n -eq 1
then
var01=$LINE
fi
if test $n -eq 2
then
var02=$LINE
fi
n=`expr $n + 1`
done < <(tr -d '\r' < /mnt/Share/hpsum_build.txt)
the above code doesn't read 2nd line that is last line '12' which doesn't end with a new line. How to read the last line as well
If your text line doesn't have an ending newline then you can do this at start of your script to force a newline in it:
echo '' >> /mnt/Share/hpsum_build.txt
You can also call dos2unix
utility to remove DOS's \r
before \n
from each line.
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句