On Wed, 17 Mar 2004, Peter Tyler wrote: > Hi > I'm trying to search and replace some "cr" and "lf" characters in a > text file (comma separated). > I want to substitute the crlf" characters (that is carriage return, > line feed, double quote.) for cr|lf" (that is carriage return, > pipe, line feed, double quote) > > The reason I am trying to do this is that I have a text (csv) file out > of Outlook that has carriage return line feeds in the address fields, > and this is causing the other fields to become miss aligned when > reading into my open office spread sheet. By changing the record > separator, I can then go through and change the inconsistencies within > the address field, then just change the record separator back to crlf. > > I have been trying the following sed 's/\x0D\x0A\"/\x0D|\x0A\"/g' but > it does not seem to pick up on the hex chars at all. So nothing is changed. > > Does anyone know an easier way of doing this? I tried hexedit but could > find a global "search and replace" function.
Not quite the solution you're after but wouldn't it be a whole lot easier to just load the XLS file into OpenOffice? Apart from that the problem with sed is it's going to see the 0x0A as a new line no matter what (had a quick look for an option to turn this off). Perhaps you can do this:- cat file | tr "\n" "\f" | sed -e 's/\r\f\"/\r\|\f\"/g' | tr "\f" "\n" >newfile The \f is a form feed and is unlikely to be in the text. -- ---<GRiP>--- Electronic Hobbyist, Former Arcadia BBS nut, Occasional nudist, Linux Guru, SLUG/AUUG/Linux Australia member, Sydney Flashmobber, BMX rider, Walker, Raver & rave music lover, Big kid that refuses to grow up. I'd make a good family pet, take me home today! Do people actually read these things? -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html