Whileループの問題(最後の行を読み取れません)

Whileループの問題(最後の行を読み取れません)

こんにちは、whileループで次の問題があります。最後の行は読みません。

  
  while IFS= read -r line
  do
       echo $line
  done<file_ref_col_master.txt

入力ファイル

FILE_ID~col_POS~COL_START_POS~COL_END_POS~datatype~delimitted_ind~col_format~columnlength
5~4~~~char~Y~\"[a-z][email protected]\"~100
5~1~~~char~Y~[0-9]+~100

電流出力

sh -x  sample1.sh
+ dos2unix /test/data/infa_shared/dev/SrcFiles/datawarehouse/poc_anjali/file_ref_col_master.txt
dos2unix: converting file /test/data/infa_shared/dev/SrcFiles/datawarehouse/poc_anjali/file_ref_col_master.txt to Unix format ...
+ n=0
+ IFS=
+ read -r line
+ echo FILE_ID~col_POS~COL_START_POS~COL_END_POS~datatype~delimitted_ind~col_format~columnlength
FILE_ID~col_POS~COL_START_POS~COL_END_POS~datatype~delimitted_ind~col_format~columnlength
+ IFS=
+ read -r line
+ echo '5~4~~~char~Y~\"[a-z][email protected]\"~100'
5~4~~~char~Y~\"[a-z][email protected]\"~100
+ IFS=
+ read -r line

ベストアンサー1

ファイルの最後の行は改行文字で終わりません。

この問題を解決する

printf "\n" >>file_ref_col_master.txt

おすすめ記事