Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 40 lines (37 sloc) 635 Bytes
#!/usr/bin/perl
# ================================================================
# John Kerl
# http://johnkerl.org
# Prints a carriage return after each ith line. E.g.
#
# $ jot 1 10 | creach 2
# 1
# 2
#
# 3
# 4
#
# 5
# 6
#
# 7
# 8
#
# 9
# 10
#
# E.g. if you have one file per month and you're doing ls -l,
# you can pipe that to creach 12 to group them by years.
# ================================================================
die "Usage: $0 {n} [input]\n" unless @ARGV;
$n = shift @ARGV;
$i = 0;
while ($line = <>) {
chomp $line;
$i++;
print "$line\n";
if ($i == $n) {
print "\n";
$i = 0;
}
}
You can’t perform that action at this time.