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?

How about doing it in Perl?

use strict; # keeping
use warnings; # myself
use Perl::Critic; # honest ;)
use Carp; # croak

my $filename = "/some/random/file.txt";
my $text;
{
    local $/; # undef the input file sep, so we don't break on \n
    open(my $fh, $filename) or croak qq("I can't even open a file, sigh");
    $text = <$fh>; # slurp
}
$text =~ s#\n#\*#gmsx; # replace \n's with *'s.  Customise to your
heart's content :)
print $text;

Hope this helps,

Michael...
-- 
Michael Davies           "Do what you think is interesting, do somthing that
[EMAIL PROTECTED]    you think is fun and worthwhile, because otherwise
http://michaeldavies.org  you won't do it well anyway." -- Brian Kernighan
-- 
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