|
|
carriage return/newline to space delineated
|
|
|
|
Mac Elite
Join Date: Oct 2001
Location: Internet
Status:
Offline
|
|
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
|
|
|
|
|
|
|
|
Mac Enthusiast
Join Date: Nov 2001
Location: Adelaide, South Australia
Status:
Offline
|
|
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
|
|
|
|
|
|
|
|
|
Mac Elite
Join Date: Oct 2001
Location: Internet
Status:
Offline
|
|
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
|
|
|
|
|
|
|
|
Forum Regular
Join Date: Oct 2002
Location: Left Coast
Status:
Offline
|
|
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 Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|