tail help
As an addition to what I was doing / am doing in https://www.linuxquestions.org/quest...54#post6299554
I want to output the last 20 lines of all the csv's in one folder to a csv in another folder. I think tail -n 20 *.csv > folder2/last-20s.csv works beautifully, I am currently using a windows computer and can't check the actual command I wrote, hence "I think". But, in the process of writing each qualifying line to last-20s.csv, I would like to, if possible, add 1) the count for total number of lines in all the csv's processed to that instant. 2) the count for number of lines processed to that instant in the individual csv being processed. 3) the name of the individual csv being processed. If the terminology is applicable to "tail" the above might amount to NR, FNR and FILENAME. If relevant and necessary, I would be using awk or gawk as it/they is/are the only programming language/s with which I have any familiarity. For reference there are 2000+ csv's being scanned with a total of well over 4,000,000 lines. Any help would be gratefully received. |
Quote:
Code:
$ tail -n3 <(seq 5) <(seq 20) Code:
$ tail -qn3 <(seq 5) <(seq 20) Quote:
With gawk, I'd try something like Code:
gawk -vOFS=, 'ENDFILE{print NR,FNR,FILENAME; print}' *.csv Code:
system("tail -n20 " FILENAME) |
Perl might do the job.
Code:
perl -a -n -e ' |
All times are GMT -5. The time now is 01:55 PM. |