Skip to content

Instantly share code, notes, and snippets.

@eduardoaugustojulio
Created September 11, 2017 18:18
Show Gist options
  • Save eduardoaugustojulio/189533e85a8ac282d1ac63b9ed98ee3c to your computer and use it in GitHub Desktop.
Save eduardoaugustojulio/189533e85a8ac282d1ac63b9ed98ee3c to your computer and use it in GitHub Desktop.
simple bash file line counter
#!/bin/bash
TOTAL=0
for i in "$@"
do
LINE_COUNT=`wc -l < "$i"`
echo "file $i have total $LINE_COUNT lines"
TOTAL=$(($TOTAL + $LINE_COUNT))
done
echo "all files together have $TOTAL lines"
@eduardoaugustojulio
Copy link
Author

to use that script do:

chmod +x line_counter.sh
./line_counter path_that_have_files/*

them they will say how many lines all files have.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment