我在一个文件夹中有一些文件,我需要每个文件夹的第一行
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
它不起作用=(