<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>Rocco</author_name>
  <author_url>https://blog.hatena.ne.jp/Rocco/</author_url>
  <blog_title>日本 GNU AWK ユーザー会 0.2</blog_title>
  <blog_url>https://rocco.hatenadiary.org/</blog_url>
  <categories>
    <anon>Netnews</anon>
  </categories>
  <description>shell variable in awk これも定石と言うか FAQ に近い問題です。基本的には '-v' オプションで渡すのが簡単で間違いがありません。 #! /bin/bash pattern=$1 cat file.c | awk '{ if($0 ~ $pattern) print $0; }' というものが動作しないと言うことですが、'-v' で渡してあげれば OK です。 pattern=$1 awk -v pattern=&quot;$pattern&quot; '$0 ~ pattern' file.c</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Frocco.hatenadiary.org%2Fentry%2F20071031%2Fp2&quot; title=&quot;shell 変数の awk での使用 - 日本 GNU AWK ユーザー会 0.2&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>https://cdn-ak.f.st-hatena.com/images/fotolife/R/Rocco/20071005/20071005231714.png</image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2007-10-31 00:00:01</published>
  <title>shell 変数の awk での使用</title>
  <type>rich</type>
  <url>https://rocco.hatenadiary.org/entry/20071031/p2</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
