[H-GEN] sed query
Jason Parker-Burlingham
jasonp at uq.net.au
Wed May 7 12:00:19 EDT 2003
[ Humbug *General* list - semi-serious discussions about Humbug and ]
[ Unix-related topics. Posts from non-subscribed addresses will vanish. ]
"Scott Pullen" <spullen at optusnet.com.au> writes:
[Please quote properly. Thanks.]
> sed -e 's/SOMETEXT/\
> SOMETEXT/g' AFILE > OUTPUTFILE
>
> The newline must be escaped and then entered. Of course the shell
> will wait until the quotes are finished before executing so all is
> well. The above answer worked well on the example text that I
> created but the real file still crashes it. I say crashes because I
> am getting no output.
Do you mean that OUTPUTFILE is a zero-byte file when the command
finishes running?
I would suggest examining the file with od, hexdump, or even cat -vet.
Any three of these programs will show you what is in the file as a
sequence of hex bytes or escaped characters so you can look for
anything untoward (but see below).
> To answer one question, the box is a Sunblade 150 running Solaris 8.
> I tried running it on the Sun V880 with 4 Gb RAM running the same OS
> and it still didn't work. I wish that I could provide the file but
> that would mean instant dismissal. Secret Squirrels and all that
> stuff.
I assume that since you're using Solaris you're using some version of
Sun's implementation of sed.
> I can only think that there must be some special characters in the
> file that I haven't noticed yet that cause this behaviour.
You have already spent 2 days by my count on this problem. Is it
possible for you to download and install GNU sed to fix this? Did you
try running the perl script I gave you? How about fmt(1)?
> I will try the other suggestions and see if I can find where in the
> file sed crashes. Hopefully not till the very end, well a couple of
> bytes short anyway.
Any version of sed that fails silently on some "bad" input is utterly
broken. Because you're not providing very good reports about your
problem it's hard to do anything but conclude that you are doing
something else wrong.
This is the stuff I would need from you to help you with your problem:
* Which version of sed are you using? You can get this information
from the manual page, the --version (or -v or -V) option, or the
output of ident(1) on the program. With this information it will be
possible to see if there are any show-stopping bugs in your sed
implementation.
* What, precisely, are you typing to the shell to try to do what you
are doing? You say that the contents of the file are secret. Does
this mean that the exact value of "SOMETEXT" is secret too? If so,
you may be able to rewrite it into an equivalent regular expression,
but telling us what "SOMETEXT" is would be vastly preferable. Does
"SOMETEXT" contain any special regular expression characters such as
^, (, ), [, ], +, *, . or $? How about backslashes? What about
shell metacharacters?
* Have you tried using any other implementations of sed, or an
equivalent program? If so, which? If not, why not? GNU sed in
particular would be helpful, as would perl, or fmt, or perhaps even
awk (depending on what you are trying to do). Even Emacs or vim
would certainly be able to edit your file and even reformat it
quickly using an appropriate macro.
If you don't or can't provide at least some of this information, then
I am very sorry but there is little I can do to keep helping you. If
you are going to respond without giving answers to these questions
then you might as well find a better use for your time because I won't
be able to help you further.
jason
--
``Oooh! A gingerbread house! Hansel and Gretel are set for life!''
--
* This is list (humbug) general handled by majordomo at lists.humbug.org.au .
* Postings to this list are only accepted from subscribed addresses of
* lists 'general' or 'general-post'. See http://www.humbug.org.au/
More information about the General
mailing list