用空格替换仅包含“ +”的行

时间:2019-09-01 15:24:33

标签: linux bash shell

我有这样的文字:

+# This is a comment
+sample text1 
+  sample_text1,
+  sample_text2,
+
 # This is a comment
 Sample text

我打算看到的输出是:

+# This is a comment
+sample text1 
+  sample_text1,
+  sample_text2,

 # This is a comment
 Sample text

如果加号是该行中的唯一字符,我尝试用空格替换加号,但是它将文件中的所有加号替换为空格。我只想选择具有单个加号的行,并用空格替换它。基本上,我想在处理时替换它,而不是实际上在文件中替换。

这是我尝试过的,但不是我打算实现的。 猫文件| tr'+'''

0 个答案:

没有答案