Operating System - HP-UX
1833780 Members
2511 Online
110063 Solutions
New Discussion

sed 's/\\//g' < /tmp/wtg1 gives Memory fault(coredump)

 
Wayne Green
Frequent Advisor

sed 's/\\//g' < /tmp/wtg1 gives Memory fault(coredump)

Trying to sed a file with long lines, over 2000 chars a line. Get a core dump trying to get rid of the "\" char.

Any other char is OK - sed 's/\|//g' or sed 's/4//g' or chars enclosing the "\" chars - sed 's/4*05775//g'.

Also get a core dump on occasion searching file for "\" char in more. Try to vi the file but get the line too long message. od -c doesn't show any dodgy chars.

Created a dummy file with "\" chars and sed can find the "\" file and remove or replace them.

Anyone with any ideas
I'll have a beer, thanks
7 REPLIES 7
S.K. Chan
Honored Contributor

Re: sed 's/\\//g' < /tmp/wtg1 gives Memory fault(coredump)

It more of a limit thing. I thing if you got more than 8k in one line it'll core dump on you. Try GNU sed .. it's more robust ..

http://hpux.cs.utah.edu/hppd/hpux/Gnu/sed-3.02/
John Strang
Regular Advisor

Re: sed 's/\\//g' < /tmp/wtg1 gives Memory fault(coredump)

Hi Wayne,

Would it be possible for you to attach a couple of lines of the file as an example? Is it possible that the \ is showing as part of a newline character, \n or a tab \t ?

John
If you never make a mistake you'll never make anything.
Wodisch
Honored Contributor

Re: sed 's/\\//g' < /tmp/wtg1 gives Memory fault(coredump)

Hello,

why don't you simply use "tr" for that:

tr -d "\\" < input.file > output.file

this would delete all backslashes from the input.file - without any problem about line-lenght limits...

Just my $0.02,
Wodisch
Wayne Green
Frequent Advisor

Re: sed 's/\\//g' < /tmp/wtg1 gives Memory fault(coredump)

I've localised the problem to a few different lines, and put this into a separate file to work on. Its wc output is 1 131 2666 /tmp/wtg1.
The previous 2 lines are OK wc output is 2 247 5306 /tmp/wtg2 so it doesn't seem to be a size limit.

od -c output of the lines with \ in below, dunno if it'll be readable though

0004640 | 1 | p r z e l - 1 1 1 0 0 0 4
0004660 5 2 8 5 4 \ 0 1 \ 0 5 7 7 5
0004700 |
0004720 3 3 8 1 5 | 0 |
0004740 0 | 0 | 0 | 0 |
0004760 | 1 | 5 1 2 6
0005000 | 1 | 0 | 0 | 5 2 4 0 3 0
0005020 3 3 7 5 | R 0 1 1 5 6
0005040 6 0 1 0 | 1 0 1 0 1 0
0005060 2 3 | 2 6 - 1 3 9 - | | N | 0
0005100 0 2 7 3 9 6 2 0 4 5 5 | 1 1 4 0
0005120 1 0 1 0 0 0 2 7 3 9 6 2 0 4 5 5
0005140 2 5 2 1 0 0 | 6 8 \n
0005152

wodisch tried your suggestion, no core dump but it didn't find the "\" char. No change to output.

Thanks for your interest.
I'll have a beer, thanks
H.Merijn Brand (procura
Honored Contributor

Re: sed 's/\\//g' < /tmp/wtg1 gives Memory fault(coredump)

Unless you want to translate \010 to the corresponding value, and just realy just want to drop the \, Wodish' tr should work, as would

# perl -pe 'tr/\\//d' infile >outfile

if you want to translate octals, you could use

# perl -pe 's/\\([0-7]+)/oct$1/ge' infile >outfile
Enjoy, Have FUN! H.Merijn
Wayne Green
Frequent Advisor

Re: sed 's/\\//g' < /tmp/wtg1 gives Memory fault(coredump)

Ran this by HP aswell and they suggested loading a patch to sed

Symptoms:
PHCO_22760:
1. sed(1) dumps core when the length of input string is
larger than 2K bytes.

once loaded it fixed the problem though dont quite see the logic here when it worked ok for a larger line. Ran other tests with files I created over 2666 chars long on other system built from same ignite tape and sed doesn't produce a core dump. Beats me so I'll just load the path on 'em all.
I'll have a beer, thanks
Wayne Green
Frequent Advisor

Re: sed 's/\\//g' < /tmp/wtg1 gives Memory fault(coredump)

Ran this by HP aswell and they suggested loading a patch to sed

Symptoms:
PHCO_22760:
1. sed(1) dumps core when the length of input string is
larger than 2K bytes.

once loaded it fixed the problem though dont quite see the logic here when it worked ok for a larger line. Ran other tests with files I created over 2666 chars long on other system built from same ignite tape and sed doesn't produce a core dump. Beats me so I'll just load the path on 'em all.

The perl command worked OK aswell. Thanks
I'll have a beer, thanks