0

I have this piece of code:

file="/dir/conf/file.config"
# while loop
while IFS='|' read -r source target filecount
do
     echo "source: ${source}"
     echo "target: ${target}"
     echo "filecount: ${filecount}"
     echo "======================="
done < "$file"

the job of this code is to read this config file:

Source1|Target1|1
Source2|Target2|2
Source3|Target3|4
Source4|Target4|3
Source5|Target5|6

The read stops at Source4 and skips the last line. How do I make sure it reads ALL the lines? Thanks!

arcee123
  • 101
  • 9
  • 41
  • 118
  • 1
    Add output of `cat -A /dir/conf/file.config` to your question. – Cyrus Jan 11 '19 at 18:01
  • 1
    This might help: [Shell script read missing last line](https://stackoverflow.com/q/12916352/3776858) or [bash: iterating through txt file lines can't read last line](https://stackoverflow.com/q/16627578/3776858) – Cyrus Jan 11 '19 at 18:03
  • that worked. Thanks! – arcee123 Jan 11 '19 at 18:07

0 Answers0