2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Bashでawkを用いて各行の先頭に#を追加しRubyのコメントアウトする

2
Posted at

Bashでawkを用いて各行の先頭に#を追加しRubyのコメントアウトする。
Rubyで複数行コメントアウトしたい時に使う。

bash
cat|awk '{print "#" $0}'

=>

p 1
puts 1
p 'あ'
p 'a'
p *1..5
p *'あ'..'お'
p *'a'..'e'

p 1

puts 1

p 'あ'

p 'a'

p *1..5

p *'あ'..'お'

p *'a'..'e'

参考

"テキストファイルの各行の先頭に文字列を追加する。

$ awk '{print "- " $0}' example.txt"

"$0
組み込み変数 $0 は、入力行(レコード)を表します。"

そのものを表示したいのになぁ…

"# コメント
-- 1行コメントは「#」のあとに書く"

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?