Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > macOS > carriage return/newline to space delineated

carriage return/newline to space delineated
Thread Tools
hadocon
Mac Elite
Join Date: Oct 2001
Location: Internet
Status: Offline
Reply With Quote
Apr 1, 2004, 07:05 PM
 
I have a rather lirge text file of the form:

<BLOCKQUOTE>
abuse
abuts
abuzz
abyes
abysm
abyss
acari
acerb
acers
ached
aches
acids
acing
acini
ackee
acmes
acned
acold
.
.
.
</BLOCKQUOTE>

I want to trun this into a file that looks like this:

<BLOCKQUOTE>
abuse abuts abuzz abyes abysm abyss acari acerb acers ached aches acids acing acini ackee acmes acned acold...
</BLOCKQUOTE>

I know this can be done with a regular expression and BBEdit. Can anyone tell me how to do this?

Thanx in advance...
20+ year MacNN forum member. MacBook Air 11" 1.6Ghz 4GB 128GB Backlit Keyboard, 4S, iPad Mini
     
Paul McCann
Mac Enthusiast
Join Date: Nov 2001
Location: Adelaide, South Australia
Status: Offline
Reply With Quote
Apr 1, 2004, 08:41 PM
 
In the find field enter

[^>]\r[^<]

and in the replace field just throw in a space. Select "use grep" and you should get
what you're after (assuming there's no leading spaces on the lines in the text file).

Cheers,
Paul
     
hadocon  (op)
Mac Elite
Join Date: Oct 2001
Location: Internet
Status: Offline
Reply With Quote
Apr 1, 2004, 09:17 PM
 
Originally posted by Paul McCann:
In the find field enter

[^>]\r[^<]

and in the replace field just throw in a space. Select "use grep" and you should get
what you're after (assuming there's no leading spaces on the lines in the text file).

Cheers,
Paul
I tried this in BBEdit, but it did not work. I just get the system bell when I try to do this.

Here is the actual file I am working with.

As I said, I need this ASAP, so any help would be very appreciated!
20+ year MacNN forum member. MacBook Air 11" 1.6Ghz 4GB 128GB Backlit Keyboard, 4S, iPad Mini
     
JNI
Forum Regular
Join Date: Oct 2002
Location: Left Coast
Status: Offline
Reply With Quote
Apr 1, 2004, 11:05 PM
 
Originally posted by hadocon:
I tried this in BBEdit, but it did not work. I just get the system bell when I try to do this.

Here is the actual file I am working with.

As I said, I need this ASAP, so any help would be very appreciated!
That file has LF endings, not CRs. So you would need to change your regexp to replace instances of '\n'.

I find this simple kind of thing easiest to do on the command line with 'tr'. No regular expressions needed.

$ tr "\n" " " < infile > outfile

That will replace an instance of any LF to a SPACE.

edit: BTW, I checked the contents of your file with 'hexdump' on the command line. The command line is your friend, especially for any kind of ASCII text file manipulation, which a cornerstone of Unix systems.
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 01:49 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,