如何grep“\\\<br/>”在文件中 [英] How to grep &quot;\n&quot; in file

查看:245
本文介绍了如何grep“\\\<br/>”在文件中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

示例文件:abc.ksh

  echo这是一个示例文件。 >> mno.txt 
echo\\\
这行有新行char。 >> mno.txt

我要

  echo\\\
这行有新行char。 >> mno.txt

作为输出。

解决方案使用 -F 来匹配固定字符串:

  $ grep -F\ n文件
echo\\\
这行有新行char。 >> mno.txt

man grep


-F, - 固定字符串

将PATTERN解释为由换行符分隔的固定字符串列表,
中的任何一个将被匹配。 (-F由POSIX指定。)



Sample file : abc.ksh

echo "This is a sample file." >> mno.txt
echo "\nThis line has new line char." >> mno.txt

I want

echo "\nThis line has new line char." >> mno.txt

as output.

解决方案

Use -F to match fixed strings:

$ grep -F "\n" file
echo "\nThis line has new line char." >> mno.txt

From man grep:

-F, --fixed-strings

Interpret PATTERN as a list of fixed strings, separated by newlines, any of which is to be matched. (-F is specified by POSIX.)

这篇关于如何grep“\\\<br/>”在文件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆