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

Re: Editing a text file with sed



On Wed, Aug 29, 2007 at 06:33:54PM +0200, Joe Hart wrote:

> On Wednesday 29 August 2007 17:36:38 Kumar Appaiah wrote:
> > On Wed, Aug 29, 2007 at 03:17:46PM +0200, Joe Hart wrote:
> > > <begin 1.txt>
> > > This is a test
> > > file, what I am
> > > trying to do is get the lines to join.
> > >
> > > It isn't a complicated thing,
> > > but I also want to keep the paragraphs
> > > separate.
> > > </end 1.txt>
> >
> > [snip]
> >
> > > But ideally I'd like to just have a script to do it, but cannot figure
> > > out how to go about it, as sed doesn't seem to be working.
> >
> > If I run your file through fmt, I get
> > <output>
> > This is a test file, what I am trying to do is get the lines to join.
> >
> > It isn't a complicated thing, but I also want to keep the paragraphs
> > separate.
> > </output>
> >
> > Of course, that may not have been what you were looking for, but I
> > just thought some might find it useful later.
> 
> I appreciate the answer, I didn't even know about the fmt command until now.  
> It does seem to work in the example, but not on the real file(s) that I am 
> working with.  Something makes me think that these files have some very 
> strange characters in them, but they don't seem to show up when I cat the 
> file.

Are they perhaps msdos-formatted?  If so does it help to dos2u them
first?  (If you don't have any better dos2u, use a file containing this: 
  perl -pi -e 's/\r\n/\n/g' $1
or similar.

-- 
richard



Reply to: