[opensource] Command line question

Eugene Talagrand talagrand.2 at osu.edu
Sun Jun 4 01:20:52 EDT 2006


How about:

perl -pe 'BEGIN { $/ = "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"; } chomp;' \
     < testfile

$/ is the record separator (lines are spearated by 15 newline characters),
-p means read in our new super-delimited lines one at a time, chomp 
means trim them and -p prints them back out.


-Eugene

On 6/4/2006 0:40, Drew Yates wrote:
>  >From a command prompt, how can I:
> 
> join together every 15 lines of a file.
> 
> that is, 15 newlines will be replaced by a space, then the 16th will be 
> skipped, then the next 15 newlines will be replaced... etc.
> 
> The furthest I've gotten is join the first 15 lines only using sed. 
> Anyone have the solution or some pointers how to solve this elegantly on 
> the command line? A bash script or little perl script would work, too.
> 
> thanks!
> 
> -Drew
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Opensource mailing list
> Opensource at cse.ohio-state.edu
> http://mail.cse.ohio-state.edu/mailman/listinfo/opensource



More information about the Opensource mailing list