[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: How to do this, fold + split



>> On Fri, 30 Dec 2011 15:09:13 +0000 (UTC), 
>> T o n g <mlist4suntong@yahoo.com> said:

T> I want to split a file every ### of chars. Is it possible not to split
T> on the word but word boundaries?

   Yup, for certain meanings of "split".  GNU fmt is part of "coreutils".
   Here's sample.txt (rulers added for readability):

   me% cat sample.txt
   ....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*
   Here is what I normally do.  Here is a skeleton script that creates a
   temporary file, redirects all output there, then if there is output it
   emails it off.  There are many ways to do this and I tinker it as
   needed.

   me% gfmt -65 sample.txt
   ....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*
   Here is what I normally do.  Here is a skeleton script that
   creates a temporary file, redirects all output there, then if
   there is output it emails it off.  There are many ways to do
   this and I tinker it as needed.

   me% gfmt -75 sample.txt
   ....*....1....*....2....*....3....*....4....*....5....*....6....*....7....*
   Here is what I normally do.  Here is a skeleton script that creates a
   temporary file, redirects all output there, then if there is output it
   emails it off.  There are many ways to do this and I tinker it as needed.

   If you want one word per line, which can be very handy:

   me% gfmt -1 sample.txt
   Here
   is
   what
   [...]
   as
   needed.

-- 
Karl Vogel                      I don't speak for the USAF or my company

A map with a bullet hole in it is still a map.  A computer with a
bullet hole in it is a paper-weight.      --why soldiers tend to like paper


Reply to: