I'd like to do a file rowcount and subtract one from it. I know how to do the first part of getting the rowcount with this function:
zcat filename$today.csv.gz | wc -l
But how do I subtract one from that value to account for headers and store it in a variable? I've tried
$(( zcat filename$today.csv.gz | wc -l - 1 ))
but that isn't working.
Do I have to store the first function's output as a variable first? Is that the recommended practice?
This one-liner can do the job:
n=$(( $(zcat filename$today.csv.gz | wc -l) - 1 ))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With