<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>zaki-hmkc</author_name>
  <author_url>https://blog.hatena.ne.jp/zaki-hmkc/</author_url>
  <blog_title>zaki work log</blog_title>
  <blog_url>https://zaki-hmkc.hatenablog.com/</blog_url>
  <categories>
    <anon>Linux</anon>
    <anon>tech</anon>
    <anon>朝活</anon>
  </categories>
  <description>コマンドの出力を正規表現使って文字列置換するならsedを使うことは多いけど、行ごとに処理するだけで「前の行の情報」などどうだったかとかの状態を維持する仕組みが(たぶん)ないので、例えば「特定の文字列パターンを正規表現で処理しつつ連番を振る」がsedは(たぶん)できない。(連番の部分) この要件ならawkを使えばできる。 お題：ps auxの結果の行頭に行番号を3桁ゼロ詰めで追加 お題そのものは全く実用的ではないけど、変数使った正規表現置換という例。 コマンドは以下。 ps aux | awk '{sub(/^/, sprintf(&quot;%03d: &quot;, ++i)); print}' AWKはsub…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fzaki-hmkc.hatenablog.com%2Fentry%2F2025%2F06%2F07%2F101434&quot; title=&quot; [Linux] AWKで正規表現置換 - zaki work log&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url></image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2025-06-07 10:14:34</published>
  <title> [Linux] AWKで正規表現置換</title>
  <type>rich</type>
  <url>https://zaki-hmkc.hatenablog.com/entry/2025/06/07/101434</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
