Mac OS替换';'在文本文件上添加新行

时间:2022-09-20 22:26:53

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

真正基本的问题我肯定对于普通的Mac用户,但是;

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.

我是一个非常新的Mac转换器,我想对文件进行快速操作。我通常会在Windows中通过搜索';'来执行此操作并在我最喜欢的编辑器(Editplus)中用'\ n'替换,但这似乎不适用于我在我的Mac上安装的两个编辑器(Coda,Espresso)。我有其他方法可以做到这一点,但我认为如果我理解为什么它不起作用会更好。

2 个解决方案

#1


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.

我猜你在查找对话框中输入替换字符串时遇到问题。如果要在任何单行Cocoa文本字段中输入换行符,则必须按⎇⃣⏎⃣(alt return)。也适用于标签。

#2


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

cat打印文件输入的内容,tr取此输出并替换;用\ n然后将其写入文件输出

#1


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.

我猜你在查找对话框中输入替换字符串时遇到问题。如果要在任何单行Cocoa文本字段中输入换行符,则必须按⎇⃣⏎⃣(alt return)。也适用于标签。

#2


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

cat打印文件输入的内容,tr取此输出并替换;用\ n然后将其写入文件输出