Skip to content

Instantly share code, notes, and snippets.

@isomorphisms
Last active January 1, 2016 11:48
Show Gist options
  • Save isomorphisms/8140037 to your computer and use it in GitHub Desktop.
Save isomorphisms/8140037 to your computer and use it in GitHub Desktop.
alternative peeking tool to head and tail: pick out a random 20 lines of a file, plus the first and last lines.
#!/bin/bash
# peek
# look at N random lines of datafile.csv
# usage: rand datafile.csv N
# rand $1 $2
head -1 $1 #names row of $1
if [ -z $2 ] ; then #IFNDEF
shuf $1 | head -20
else
shuf $1 | head -$2 #N=$2
fi
tail -1 $1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment