1829116 Members
2294 Online
109986 Solutions
New Discussion

sed help

 
Steven Chen_1
Super Advisor

sed help

I have used sed to replace one word in a file, but the replaced file can't be open by a form engine. (the file is form file, but can be regarded as text doc)

I am badly need help:
1) any parameter should be used to keep original lines/patern intact?
2) any other program is better in serving this purpose?

Thanks a lot,

Steven
Steve
3 REPLIES 3
Rodney Hills
Honored Contributor

Re: sed help

sed works good for changing text in a file.

If you compared the original with the new and the differences only shows the word you changed, then I suspect the application may not tolerate text changes. For example a tar save has a checksum in it and if you change just one character in the file, the checksum will be incorrect and tar will say its a bad tar file.

It is possible your "form" application could have some sort of dependency like that.
There be dragons...
Steven Chen_1
Super Advisor

Re: sed help

After sed, the file seems to have sth missing that form engine claims to have some table missing.

Since I have >700 files need to be changed, if I have to change them manually in wordpad, or form editor, the world is dead.

What if other editor such as ed?

Steve
Rodney Hills
Honored Contributor

Re: sed help

Since you mentioned "wordpad", I assume these are PC text files. A PC text file ends each line with CR/LF, where unix text files end with LF only.

If this is not handled correctly, a PC application could get confused about the data.
(for instance you use ftp to transfer the files and select the ascii option one time, and binary the other).

Other bulk editors do exist on hpux, like awk and perl. But "sed" is a safe edittor for text changing. Compare the old file to the new (using diff command) and validate the change you are doing, is being done correctly.
There be dragons...