从文件中 Grep 一行

从文件中 Grep 一行

我想从包含超过 5000 条行块的文件中仅提取行块。如何使用 grep 来做到这一点?

ATOMIC_POSITIONS crystal
 Ti   0.3333335000000000  0.1666670000000000  0.4568808285000000
 Ti   0.8333334999999999  0.1666670000000000  0.4568808285000000
 Ti   0.3333335000000000  0.6666670000000000  0.4568808285000000
 Ti   0.8333334999999999  0.6666670000000000  0.4568808285000000
 Ti   0.3333335000000000  0.1666670000000000  0.9568808285000000
 Ti   0.8333334999999999  0.1666670000000000  0.9568808285000000
 Ti   0.3333335000000000  0.6666670000000000  0.9568808285000000
 Ti   0.8333334999999999  0.6666670000000000  0.9568808285000000
 Ti   0.1666665000000000  0.3333330000000000  0.2068808285000000
 Ti   0.6666665000000001  0.3333330000000000  0.2068808285000000
 Ti   0.1666665000000000  0.8333330000000000  0.2068808285000000
 Ti   0.6666665000000001  0.8333330000000000  0.2068808285000000
 Ti   0.1666665000000000  0.3333330000000000  0.7068808285000000

 Ti   0.6666665000000001  0.3333330000000000  0.7068808285000000
 Ti   0.1666665000000000  0.8333330000000000  0.7068808285000000
 Ti   0.6666665000000001  0.8333330000000000  0.7068808285000000
 Ti   0.1666665000000000  0.3333330000000000  0.0431191715000000
 Ti   0.6666665000000001  0.3333330000000000  0.0431191715000000
 Ti   0.1666665000000000  0.8333330000000000  0.0431191715000000
 Ti   0.6666665000000001  0.8333330000000000  0.0431191715000000
 Ti   0.1666665000000000  0.3333330000000000  0.5431191715000000
 Ti   0.6666665000000001  0.3333330000000000  0.5431191715000000
 Ti   0.1666665000000000  0.8333330000000000  0.5431191715000000
 Ti   0.6666665000000001  0.8333330000000000  0.5431191715000000
 Ti   0.3333335000000000  0.1666670000000000  0.2931191715000000
 Ti   0.8333334999999999  0.1666670000000000  0.2931191715000000
 Ti   0.3333335000000000  0.6666670000000000  0.2931191715000000
 Ti   0.8333334999999999  0.6666670000000000  0.2931191715000000
 Ti   0.3333335000000000  0.1666670000000000  0.7931191715000000
 Ti   0.8333334999999999  0.1666670000000000  0.7931191715000000
 Ti   0.3333335000000000  0.6666670000000000  0.7931191715000000
 Ti   0.8333334999999999  0.6666670000000000  0.7931191715000000
 Cd   0.3333335000000000  0.1666670000000000  0.1250000000000000
 Cd   0.8333334999999999  0.1666670000000000  0.1250000000000000
 Cd   0.3333335000000000  0.6666670000000000  0.1250000000000000
 Cd   0.8333334999999999  0.6666670000000000  0.1250000000000000
 Cd   0.3333335000000000  0.1666670000000000  0.6250000000000000
 Cd   0.8333334999999999  0.1666670000000000  0.6250000000000000
 Cd   0.3333335000000000  0.6666670000000000  0.6250000000000000
 Cd   0.8333334999999999  0.6666670000000000  0.6250000000000000
 Cd   0.1666665000000000  0.3333330000000000  0.3750000000000000
 Cd   0.6666665000000001  0.3333330000000000  0.3750000000000000
 Cd   0.1666665000000000  0.8333330000000000  0.3750000000000000
 Cd   0.6666665000000001  0.8333330000000000  0.3750000000000000
 Cd   0.1666665000000000  0.3333330000000000  0.8750000000000000
 Cd   0.6666665000000001  0.3333330000000000  0.8750000000000000
 Cd   0.1666665000000000  0.8333330000000000  0.8750000000000000
 Cd   0.6666665000000001  0.8333330000000000  0.8750000000000000
  C   0.0000000000000000  0.0000000000000000  0.0000000000000000
  C   0.5000000000000000  0.0000000000000000  0.0000000000000000
  C   0.0000000000000000  0.5000000000000000  0.0000000000000000
  C   0.5000000000000000  0.5000000000000000  0.0000000000000000
  C   0.0000000000000000  0.0000000000000000  0.5000000000000000
  C   0.5000000000000000  0.0000000000000000  0.5000000000000000
  C   0.0000000000000000  0.5000000000000000  0.5000000000000000
  C   0.5000000000000000  0.5000000000000000  0.5000000000000000
  C   0.0000000000000000  0.0000000000000000  0.2500000000000000
  C   0.5000000000000000  0.0000000000000000  0.2500000000000000
  C   0.0000000000000000  0.5000000000000000  0.2500000000000000
  C   0.5000000000000000  0.5000000000000000  0.2500000000000000
  C   0.0000000000000000  0.0000000000000000  0.7500000000000000
  C   0.5000000000000000  0.0000000000000000  0.7500000000000000
  C   0.0000000000000000  0.5000000000000000  0.7500000000000000
  C   0.5000000000000000  0.5000000000000000  0.7500000000000000

答案1

我猜您正在寻找某种东西来处理由空行分隔的数据组?

基于这个假设,我认为你实际寻找的可能是awk(而不是grep)。具体来说,这可能就是:https://www.gnu.org/software/gawk/manual/html_node/Multiple-Line.html

相关内容