#!/usr/bin/perl open(OUT,">output.txt") or die("Couldn't open output file\n"); while ($chunk = read(<>,60)) { printf(OUT, "%s\n", $chunk); } close(OUT); #!/bin/sh # turn off field separators export IFS='' export OFS='' # delete the output file, if it exists [ -f junk ] && rm junk # read 60 characters from stdin read -n 60 str while [ ! -z "$str" ] do # if str isn't empty, echo to the output file echo "$str" >> junk # read 60 more characters; wash, rinse, repeat read -n 60 str done