すべてを | |
▼開く |
閉じる▲ |
$ cat desc.txt Sed is a streaming editor that is used to perform basic text transformations on an input streaming (a file or input from a pipeline).sedコマンドで置換文字列を指示し、ファイルを与える
$ sed 's/streaming/stream/g' < desc.txt Sed is a stream editor that is used to perform basic text transformations on an input stream (a file or input from a pipeline).
sedコマンドで、置換文字列を「's/streaming/stream/g'」、ファイル「desc.txt」をリダイレクトでコマンドに与えると、ファイル中の文字列「streaming」をすべて「stream」に変換する。
置換文字列の指定方法 |
---|
's/置換する文字列/新しい文字列/g' |
正規表現などがシェルに解釈されないように引用符「'」で囲む
trコマンドに置換を指示する「s」
「/」に続いて置換する文字列を指定
「/」に続いて新しい文字列を指定
「/」で閉じる
trコマンドにすべて置換を指示する「g」
Copyright iDesign Inc., 2005-2012