「sed」の編集履歴(バックアップ)一覧はこちら
「sed」(2006/01/30 (月) 02:20:19) の最新版変更点
追加された行は緑色になります。
削除された行は赤色になります。
*sed
**読み方
- [[sed]]
- [[セド>sed]]
- [[セッド>sed]]
**意味
- Stream EDitor
**サンプル
- まず、サンプルデータの登録されたファイルを作成する。
$ echo "abcdef" > sample1.txt
$ cat sample1.txt
abcdef
***サンプル1
- 以下のコマンドを実行する。
$ sed s/abc/def/ < sample1.txt > sample2.txt
- 結果
$ cat sample2.txt
defdef
***サンプル2
- 以下のコマンドを実行する。
$ ls
perl/ sample.txt sample1.txt sample2.txt
$ ls | sed 's/[a-z]/x/g'
- 結果
xxxx/
xxxxxx.xxx
xxxxxx1.xxx
xxxxxx2.xxx
***サンプル3
- 以下のコマンドを実行する。
$ cat sample1.txt | sed 's/abc/ABC/'
- 結果
ABCdef
***サンプル3
- 以下のコマンドを実行する。
$ cat sample1.txt | sed 's/abc/ABC/'
- 結果
ABCdef
***サンプル4
- 以下のコマンドを実行する。
$ cat sample.txt | sed 's/\([ab]\).\([def]\)/\1X\2/g'
- 結果
abXdef
***サンプル5(perlで行う。)
- 以下のコマンドを実行する。
$ perl -pe 's/abc/def/g' < sample1.txt
- 結果
defdef
*sed
**読み方
- [[sed]]
- [[セド>sed]]
- [[セッド>sed]]
**意味
- Stream EDitor
**サンプル
- まず、サンプルデータの登録されたファイルを作成する。
$ echo "abcdef" > sample1.txt
$ cat sample1.txt
abcdef
***サンプル1
- 以下のコマンドを実行する。
$ sed s/abc/def/ < sample1.txt > sample2.txt
- 結果
$ cat sample2.txt
defdef
***サンプル2
- 以下のコマンドを実行する。
$ ls
perl/ sample.txt sample1.txt sample2.txt
$ ls | sed 's/[a-z]/x/g'
- 結果
xxxx/
xxxxxx.xxx
xxxxxx1.xxx
xxxxxx2.xxx
***サンプル3
- 以下のコマンドを実行する。
$ cat sample1.txt | sed 's/abc/ABC/'
- 結果
ABCdef
***サンプル4
- 以下のコマンドを実行する。
$ cat sample.txt | sed 's/\([ab]\).\([def]\)/\1X\2/g'
- 結果
abXdef
***サンプル5(perlで行う。)
- 以下のコマンドを実行する。
$ perl -pe 's/abc/def/g' < sample1.txt
- 結果
defdef