Can you help me please?
I know that
wc -l *.txt
gives you the number of lines in each file. But how can i count the files that have over n lines?
Can you help me please?
I know that
wc -l *.txt
gives you the number of lines in each file. But how can i count the files that have over n lines?
Note, I did the grep to exclude the total line; perhaps other ways to accomplish this also.
> wc -l * | grep -v " total"
0 delete_extra
18 file01
3 file01k
3 file02
4 file05
4 file06
4 file08
4 file09
3 file10
0 file11
1 file12
5 file13
7 file14
7 file14n
5 file15
12 file15_1
3 file20
25 file21
4 file22
17 file23
3 file24
0 pass_var
10 play_file14
0 resnum
0 scsi35
8 sort_22
> wc -l * | grep -v " total" | awk '$1>10'
18 file01
12 file15_1
25 file21
17 file23
One way -
[code]
n=42
wc -l *.txt | awk -v n=$n '$1>n' | wc -l
/code]
Without needing the grep, as in my previus example
(to exclude the total line)
> wc -l * | awk '$2!="total" && $1>10'
Assuming 100 lines.
If you have GNU awk:
awk 'FNR>100{print FILENAME;nextfile}' *
Otherwise (use nawk or /usr/xpg4/bin/awk on Solaris):
awk 'FNR>100&&!_[FILENAME]++{print FILENAME}' *
With Perl:
perl -lne'print $ARGV and close ARGV if $.>100' *