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

Re: Editing a text file with sed



Single quotes go around the whole sed script unless you are using a
separate sed script file.
try      sed 's/\n//' 1.txt > 2.txt

 - Adam

On 8/29/07, Florian Kulzer <florian.kulzer+debian@icfo.es> wrote:
> On Wed, Aug 29, 2007 at 15:17:46 +0200, Joe Hart wrote:
> >
> > I am having trouble using sed to edit text files, heres a good example of what
> > I am looking for:
> >
> > <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>
>
> [...]
>
> > 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.
>
> Why not use Perl?
>
> $ perl -p0e '$_=~s/(.)\n(.)/$1 $2/g' < 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.
>
> $ perl -p0e '$_=~s/(.)\n(.|\n)/$1 $2/g;$_=~s/ \n/\n/g' < 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.
>
> --
> Regards,            | http://users.icfo.es/Florian.Kulzer
>           Florian   |
>
>
> --
> To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
> with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
>
>



Reply to: