bash: iterating through txt file lines can't read last line

后端 未结 3 956
野的像风
野的像风 2021-01-20 15:21

while read p; do
echo $p
done < file.txt

this code can read all lines in the file.txt except the last line any

3条回答
  •  我在风中等你
    2021-01-20 16:01

    cat file.txt and see if the very last line has a new line at the end of the last line or not. If it does not then while read p ; do echo $p done < file.txt won't echo the last line put a new-line at the end of the last line in the text file

提交回复
热议问题