Skip to content

Instantly share code, notes, and snippets.

@mkuprionis
Created November 16, 2012 06:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mkuprionis/4084888 to your computer and use it in GitHub Desktop.
Save mkuprionis/4084888 to your computer and use it in GitHub Desktop.
Bash snippets
# Print file names with line numbers sorted ascending
for f in $(find . -iname "*.java"); do echo $f `(cat $f | wc -l)`; done | sort -k2 -n
# Total line count in directory
for f in $(find . -iname "*.java"); do cat $f; done | wc -l
# Copy files from multiple directories to a single one (filenames contain whitespace)
SAVEIFS=$IFS; IFS=$(echo -en "\n\b"); for f in $(find . -iname "*_new.png"); do cp $f ~/tmp/md/; done; IFS=$SAVEIFS;
# Total changed lines since some date from Git log
git log --numstat --pretty="%H" --no-merges --since "2012-11-18" --author "Mindaugas Kuprionis" | awk 'NF==3 {plus+=$1; minus+=$2} END {printf("%d (+%d, -%d)\n", plus-minus, plus, minus)}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment