【问题标题】:Grep command with "${sta}~${stp}!d"带有“${sta}~${stp}!d”的 Grep 命令
【发布时间】:2021-12-30 12:02:21
【问题描述】:

我遇到了以下代码。 "${sta}~${stp}!d" 应该做什么?

grep --null -r -l "${isufx[@]}" -e "$ptrn" -- "${fdir[@]}" |
  sed -z "${sta}~${stp}!d"

【问题讨论】:

  • 这取决于变量stastp 的设置。
  • 它们是整数。我突然想到它可能会跳过find 命令传递的一些文件。

标签: bash sed


【解决方案1】:

来自https://www.gnu.org/software/sed/manual/sed.html#Numeric-Addresses

first~step

This GNU extension matches every stepth line starting with line first.

【讨论】:

  • 也许添加:而!d 表示不要删除该行。示例:使用 first=21 和 step=2 删除除从第 21 行开始的奇数行之外的所有行。
猜你喜欢
  • 2016-12-19
  • 2012-07-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-09-23
  • 2016-07-26
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多