Bash grep 某物。然后找到位置
我一直想知道这个问题; 假设我首先尝试从文件中 grep 一些行:
cat 101127_2.bam |grep 'TGATTACTTGCTTTATTTTAGTGTTTAATTTGTTCTTTTCTAATAA'
然后它会弹出包含该字符串的整行。 但是,我们可以使用一些简单的bash代码来定位这个字符串所在的行吗? (第 100 个?第 1000 个?...)
I've long been wondering about this question;
say I first try to grep some lines from a file:
cat 101127_2.bam |grep 'TGATTACTTGCTTTATTTTAGTGTTTAATTTGTTCTTTTCTAATAA'
Then it'll pop out the whole line containing this string.
However, can we use some simple bash code to locate at which line this string locates? (100th? 1000th?...)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我使用
man grep
找到它并编写/行号
// 编辑:谢谢@Keith Thompson 我正在编辑
cat 文件 | 的帖子grep -n 模式
到grep -n 模式文件
,我很着急抱歉I found it using
man grep
and writing/line number
// EDIT: Thanks @Keith Thompson I'm editing post from
cat file | grep -n pattern
togrep -n pattern file
, I was in a hurry sorry试试这个:
try this:
这可能也适合您:
或
上述解决方案仅输出匹配的行号,以查看也匹配的行:
或
This might work for you too:
or
The above solutions only output the matching line numbers, to see the lines matched too:
or