フォルダーにいくつかのファイルがあり、各フォルダーの最初の行が必要です
transaction1.csv
transaction2.csv
transaction3.csv
transaction4.csv
そして私は次のコードを持っています
#All folders that begin with the word transaction
folder='"transaction*"'
ls `echo $folder |sed s/"\""/\/g` >testFiles
# The number of lines of testFiles that is the number of transaction files
num=`cat testFiles | wc -l`
for i in `seq 1 $num`
do
#The first transaction file
b=`cat testFiles | head -1`
#The first line of the first transaction file
cat `echo $b` | sed -n 1p
#remove the first line of the testFiles
sed -i '1d' testFiles
done
このコードは機能します。問題は、各ファイルの最初の行をファイルに保存する必要があることです
行を変更した場合:
cat `echo $b` | sed -n 1p > salida
動作しません =(