Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mac OS replace ';' with new line on text file

Tags:

Really basic question I'm sure for the normal Mac user but;

I'm a very recent Mac convert and I want to do a quick operation on a file. I would normally do this in windows by doing a search for ';' and replace with '\n' in my favourite editor(Editplus) but this doesn't seem to work on the two editors I have installed (Coda, Espresso) on my mac. I have other ways of doing this but I figured it would be better if I understood why it wasn't working.

like image 734
Derek Organ Avatar asked Jun 08 '09 13:06

Derek Organ


People also ask

How do I insert a new line in Find and Replace?

Select the cells that you want to search. On the keyboard, press Ctrl + H to open the Find and Replace dialog box, with the Replace tab active. On the Replace tab, click in the Find What box. On the keyboard, press Ctrl + J to enter the line break character.

How do I replace enter in a text file?

Open TextPad and the file you want to edit. Click Search and then Replace. In the Replace window, in the Find what section, type ^\n (caret, backslash 'n') and leave the Replace with section blank, unless you want to replace a blank line with other text. Check the Regular Expression box.


2 Answers

I guess you have problems entering the replace string in the find dialog. If you want to enter a newline in any single line Cocoa text field, you have to press ⎇⃣⏎⃣ (alt return). Also works for tab.

like image 87
Nikolai Ruhe Avatar answered Nov 10 '22 06:11

Nikolai Ruhe


You can do this on the command line in the Terminal with:

cat input | tr ";" "\n"  > output

cat prints the content of the file input, tr takes this output and replaces ; with \n and this is then written into the file output

like image 30
seb Avatar answered Nov 10 '22 04:11

seb