Reputation: 1
csv file in excel and saved it as .txt and when I count the lines using wc -l there is one line less in the .txt format 17768 vs 17769. 1. Is this normal and if so which line is lost in the conversion? 2. What is the easiest way to make this conversion in bash? Thanks!
Upvotes: 0
Views: 393
Reputation: 2705
wc -l
count records based on row delimiter (\n
) most probably your last record do not have row delimiter.
For example echo
commands add a new line at the end but printf
won't.
Demo:
$echo -e "1\n2" | wc -l
2
$printf "1\n2" | wc -l
1
$
$echo -e "1\n2" | od -c
0000000 1 \n 2 \n
0000004
$printf "1\n2" | od -c
0000000 1 \n 2
0000003
$
Both printf and echo are print 2 records. But as we don't have row delimiter (\n
) at the end of string wc
is showing only 1 record
$echo -e "1\n2"
1
2
$printf "1\n2"
1
2$
Upvotes: 1