0
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 3 years have passed since last update.

【bash】edコマンドの活用(大量のファイルを同じ手順で編集したい)

Last updated at Posted at 2020-07-19

はじめに

sed, awk, tr, sort, viなどUNIX系OSには様々なテキスト処理系のコマンドがありますが、その中の一つedコマンドを紹介します。

使う場面

タイトル通りです。sed, awk, tr, sort は入力ファイルと出力ファイルが異なります。viはファイル1つ1つを都度開いて編集する必要があります。

edvi に分類されるものですが、ちょっとしたテクニックを知っているとバッチ処理で使う場面がでてきます。

スクリプト

スペースをタブに変更します。

# !/usr/bin/bash

ed $1 <<__END__
p
s/ /    /g
p
w
q
__END__
  • コマンドは sed, vi を知っているなら分かると思います。

備考

grepは、「g(global)+re(正規表現)+p(print)」の略なんだそうです。

0
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
0
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?