LoginSignup
4
5

More than 5 years have passed since last update.

sedコマンドでcsvファイルの各行の末尾のカンマを消しちゃう

Last updated at Posted at 2017-03-01

概要

  • sedコマンドで行末のカンマを空白に置換

環境

  • Ubuntu 14.04LTS (VMWare上)

sedとは

  • 文字列を全置換したり、行単位で抽出したり、削除したり、いろいろなテキスト処理のできるコマンドのこと
  • 置換の場合 sed "s/<置換前>/<置換後>/" てな感じでやる。 ファイルを直接書き換える場合は、-iコマンドを追加する。
    • <置換前>の後に\$追加すると行末にある文字列<置換前>を置換してくれる。

やり方

by_comma.sh
sed -i -e "s/,\$//" comma.csv

参考文献

4
5
2

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
4
5