perl -n -e '$n = 4 if /^id:/; if ($n) { print; $n--; }' your_data_file