#!/bin/bash tmpfile=$(mktemp) cat ${1} | awk '{print $0} NR%'${2}'==0 {printf "\n"}' > ${tmpfile} mv ${tmpfile} ${1}