grep找到包含“ \t" [英] grep find lines that contains " \t"
问题描述
我被要求制作一个shell脚本来检查文件中的简单错误。
我想找到每行$ if
$ b
(正则表达式:)[] \ t。/ b>
问题在于grep忽略了\并将t作为文字。我也尝试在文件中写入字符本身,并要求grep读取它,但它不起作用。
有没有办法在文件中使用任何常用的linux工具(如grep)找到正则表达式\ t?
我已经尝试过:
grep -E --ignore-case --line-number --with-filename --file =b文件
(b包含:)
还有:
grep -E --ignore-case --line-number --with-filename --regexp =[\t]file
您可以使用C风格的字符串 $'...'
grep $'\t'file.txt
或 sed
:
sed -n'/ \ t / p'file.txt
I was requested to make a shell script to check for simple mistakes in files. I wanted to find, for each line if
(regex:) "[ ]\t" ever happens.
The problem is that grep is ignoring the \ and is taking "t" as a literal. I also tried writting the characters themselves in a file and asking grep to read it but it didn't work. Is there a way to find for the regex " \t" in files using any of the usual linux tools (like grep)?
I already tried:
grep -E --ignore-case --line-number --with-filename --file="b" file
(b contains: " ") and also:
grep -E --ignore-case --line-number --with-filename --regexp=" [\t]" file
You can use C-style string $'...'
grep $'\t' file.txt
Or sed
:
sed -n '/\t/p' file.txt
这篇关于grep找到包含“ \t"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!