Created
May 3, 2017 07:02
-
-
Save petrelharp/81bd7ac59d6bcdbeae674d087f44c0c6 to your computer and use it in GitHub Desktop.
View a file with lots of columns in chunks of N columns
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
USAGE="Split a file up into chunks of N columns. | |
Usage: | |
$0 N file | |
" | |
if [ $# -lt 2 ] | |
then | |
echo "$USAGE" | |
exit 0 | |
fi | |
N=$1 | |
shift | |
FILE=$1 | |
shift | |
NCOL=$(head -n 1 $FILE | wc -w) | |
START=1 | |
while [ $START -le $NCOL ] | |
do | |
END=$((START+$N)) | |
cut $* -f $START-$END $FILE | column -t | |
START=$((START+$N)) | |
echo "" | |
echo "..........................................................." | |
echo "" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment