在linux下如何提取指定字符串的几行

MrBayes block for partition definitionsWarning: MrBayes only allows a relatively small collection of models. If any model in your analysis is not one that is included in MrBayes (e.g. by setting nst = 1, 2, or 6 for DNA sequences; or is not in the available list of protein models for MrBayes)then this MrBayes block will just set that model to nst = 6 for DNA, or 'wag' for Protein. Similarly, the only additional parameters that this MrBayes block will include are +I and +G. Other parameters, such as +F and +X, are ignored. If you want to use this MrBayes block for your analysis, please make sure to check it carefully before you use it we've done our best to make it accurate, but there may be errors that remain!begin mrbayes; charset Subset1 = 1-504\3 2-504\3; charset Subset2 = 3-504\3; partition PartitionFinder = 2:Subset1, Subset2; set partition=PartitionFinder; lset applyto=(1) nst=6 rates=gamma; lset applyto=(2) nst=6 rates=gamma; prset applyto=(all) ratepr=variable; unlink statefreq=(all) revmat=(all) shape=(all) pinvar=(all) tratio=(all); unlink brlens=(all);end;*Citations for this analysis*-----------------------------If you use this analysis in your published work, please cite the following papers on which your analysis relied.想提取从begin mrbayes;到end;这几行的内容,包括begin mrbayes;和end;

使用awk好像有此功能可以截取特定的行
^begin指的是以begin开头的行
一直到
^end开头的行

awk "^begin","^end"{print $0} /path/file
/path路径 /file即为文件名
如果想了解更多功能的话 百度awk吧呵呵追问

首先我这个文件中以begin开头和以end开头的行有很多,我只需要从begin mrbayes到下面end这几行,而且具体的行数也不固定。

追答

哦 那你这个现在显示的文档只是一部分咯?

我只是猜测这么处理的,,但是你如果有多行的话,,那就需要通过管道再先进进一步的过虑了哦 而且过虑规则都得变化,,因为你之前说的就是begin - end
你要再进一步过虑的话,,那可就得再找其它的begin ~end之间的特点才能过虑出来。。。 呵呵 具体的我就不清楚了哦嘻嘻 不过我可以试试,,你先回复吧,,呵呵,,看看你要找什么样特性的行

你可以直接学习一下awk感觉非常强大哈哈

温馨提示:答案为网友推荐,仅供参考
相似回答