タグ

ブックマーク / diary.overlasting.net (2)

  • [O] sedとgrepで、あるディレクトリ以下のファイル中の文字列を一括置換

    sedとgrepで、あるディレクトリ以下のファイル中の文字列を一括置換 Tweet [Programming] あるディレクトリ以下の、とある文字列を含むファイルのうち、 一部のファイルを除く全てのファイルを対象に、 文字列置換を一括してかけた。sedとgrepを使用した。 忘れそうなのでメモしておく。 % grep -lr とある文字列 * | grep -v '除外するパス' | xargs sed -i 's/とある文字列/置換後の文字列/g' grepの-lオプションでマッチするファイル名だけ出力。 grepの-vオプションで。ファイルリストから除外したい文字を入力。 邪魔なものが沢山あるときは-vオプションで繰り返しフィルタリング。 sedの-iオプションで一括置換する。

    a_bicky
    a_bicky 2012/01/25
    文字列一括置換
  • overlasting.net

    overlasting.net 2019 Copyright. All Rights Reserved. The Sponsored Listings displayed above are served automatically by a third party. Neither the service provider nor the domain owner maintain any relationship with the advertisers. In case of trademark issues please contact the domain owner directly (contact information can be found in whois). Privacy Policy

  • 1