macos Mac OS 替换 ';' 在文本文件上有新行

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/964945/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 06:12:13  来源:igfitidea点击:

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

macostext-editor

提问by Derek Organ

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)。我有其他方法可以做到这一点,但我认为如果我理解它为什么不起作用会更好。

回答by Nikolai Ruhe

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 文本字段中输入换行符,则必须按 ???? (替代返回)。也适用于选项卡。

回答by seb

You can do this on the command line in the Terminalwith:

您可以在终端的命令行上使用以下命令执行此操作:

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

catprints the content of the file input, trtakes this output and replaces ;with \nand this is then written into the file output

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