0

hello i have below issue in the while loop , it is not reading last line .

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

input file

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

current output

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

2

1 Answer 1

2

The last line of the file doesn't end with a newline.

Fix that with

printf "\n" >>file_ref_col_master.txt

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.