LoginSignup
9
11

More than 5 years have passed since last update.

複数のcsvファイルを結合するシェルスクリプト(1個目のファイル以外は1行目を削除)

Posted at

複数のcsvファイルを結合するバッチ(1個目のファイル以外は1行目を削除)
を書きましたが、
シェルスクリプトでも書いてみました。

join.sh
#!/bin/sh

counter=0

for file in `\find . -maxdepth 1 -name '*.csv'`;
do
    echo $file
    if [ $counter == 0 ]; then
        cat $file > result.csv
    else
        sed -e '1d' $file >> result.csv
    fi
    counter=`expr $counter + 1`
done

read -p "Press [Enter] key to resume."
9
11
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
9
11