GNU Awk 3.0.6 + multi-byte extension 1.15
前準備 として ファイルを作成 最初は 空白の行が 3行あるもの これを ” test”として 作成 次に awk を 操作するために その 内容を 記載した スクリ プト ”awkscr”を 作成する、操作する内容は 空白行が ある場所で 文字列を 画面に 出力させる という内容 である 。
Pmt> echo "First line" >test
Pmt> echo "" >>test
Pmt> echo "Second Line">>test
Pmt> echo "" >>test
Pmt> echo "Third Line">>test
Pmt> echo "" >>test
Pmt> echo "Last Line">>test
Pmt> cat test
First line
Second Line
Third Line
Last Line
Pmt> echo '/^$/ { print "This is a blank line." }' >awkscr
Pmt> cat awkscr
/^$/ { print "This is a blank line." }
Pmt> cat -n test
1 First line
2
3 Second Line
4
5 Third Line
6
7 Last Line
ほたら その 使用方法は 以下の 様にして 使用する
Pmt> awk -f awkscr test This is a blank line. This is a blank line. This is a blank line.
ほんでもって 今度は ”awkscr”に 追加の操作をさせてみる。
Pmt> echo '{print}' >>awkscr
Pmt> cat awkscr
/^$/ { print "This is a blank line." }
{print}
Pmt> awk -f awkscr test
First line
This is a blank line.
Second Line
This is a blank line.
Third Line
This is a blank line.
Last Line
こういう感じです、この使いかた
Pmt> awk -f awkscr test awk -f awkscr test
awkscr を 使用するための -f は 小文字の ”f ”である 事に 留意しておく事 大文字では おへん。
にゃんたろう 拝!
GNU Awk 3.0.6 + multi-byte extension 1.15
2006年12月26日 (火) 23:30:40 JST 作成