Reputation: 669
I have the command "find . -name '*.dmp' | xargs wc -l" to get the lines from all the dmp files in a directory. The dump files naming convention is "dump-10181.dmp" with the number being a unique incremental number.
How do I get the number of lines for only files with the number 50 - 678?
Upvotes: 2
Views: 102
Reputation: 6208
Longer than other solutions but more general:
for f in *.dmp ; do \
n=${f##*-}; n=${n%.dmp}; \
[[ "$n" = "" || "$n" = *[^0-9]* ]] && continue ;\
n=$((10#$n)) ; ((n >= 50 && n <= 678)) && cat "./$f" ;\
done | wc -l
Upvotes: 1
Reputation: 15194
Try the following:
seq 50 678 | xargs -I'{}' cat dump{} | wc -l
Upvotes: 2