1
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.

よく使うsedコマンド集

Last updated at Posted at 2019-03-31

こちらの記事から切り出し

オプション
-e スクリプトを追加
-i 上書き更新
Windows改行コード「\r\n」をLinuxの「\n」に変換する
sed -ie 's/\r//' ファイル
ファイルに対して該当行の前に(i)文字列を追加する
sed -ie '行数i 追加文字列' 対象ファイル
ファイルに対して該当行の前に(a)文字列を追加する
sed -ie '行数a 追加文字列' 対象ファイル
ファイルに対して該当行を削除(d)する
sed -ie '行数d' 対象ファイル
タブをスペースに変換するスクリプトを実行
sed -ie 's/<tab>/<space>/g' 対象ファイル
該当行の範囲の頭の「#」を外す
sed -ie "開始行数,終了行数s:^#::" 対象ファイル
ファイルに対してスペースと一緒に文字列を追加
sed -ie '行数i \ 文字列' 対象ファイル
ファイルに対して対象文字列に合致する行をコメントアウトする
sed -ie '/対象文字列/s/^/# /g' 対象ファイル
1
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
1
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?