0
0

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.

複数CSVを結合するワンライナー

Last updated at Posted at 2021-08-23

別にCSVじゃなくても使える(ヘッダー処理部とか消して)

  • ヘッダーをつけるために初手に1行目を出力(head -n 1 > result)
  • 1行目飛ばしで出力(sed -e '1d' {})
  • 末尾に改行が無いパターンもあるのでパイプでawkをかます(| awk 1)
cat *.csv | head -n 1 > result && find . -name "*.csv" -exec sh -c "sed -e '1d' {} | awk 1 >> result" \;

注意としてresult.csvに出力すると無限ループして巨大な化け物を製造しつつ固まる(一敗)

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?