On Wed, 2007-10-03 at 18:44 +1000, Amos Shapira wrote:
> On 03/10/2007, david <[EMAIL PROTECTED]> wrote:
> >
> > I want to edit a multi line file as if it were all one line
> >
> > In other words, treat \n like any other character, and specifically
> > doing global find and replace.
> >
> > I know there are various hex editors, but they are all pretty clunky as
> > far as I can see, and none seem to be able to do that from command line.
> >
> > Is there a shell script way to do it?
> 
> 
> Can you be more specific of what you are trying to achieve?
> 


[EMAIL PROTECTED]:~/test/testdir $ cat > test
1 
2
3
[EMAIL PROTECTED]:~/test/testdir $ sed s/1\n/1/g test 
1
2
3
[EMAIL PROTECTED]:~/test/testdir $ 

The output I would have liked would be:

12
3

but sed doesn't seem to work like that. Pity. I'm pretty sure you can't
get vim to do it either. I'm assuming vim just uses sed anyway?







> A brief look at sed(1) (GNU sed 4.1.5 on Debian Etch) shows that "\n" in
> regular expressions will be treated as a newline, and in perl you can add
> "//s" modifier to make perl treat strings as single line (see perlre(1)).
> 
> Also it might be worth digging the excellent vim.org web site, I wouldn't be
> surprised to find something there that will tell you how to do that using
> VIM.
> 
> --Amos

-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to