Linux批文本文件处理
2022-04-21 本文已影响0人
倪桦
fileList=`find $PWD -name "anno_report.csv"`
:>anno_report.table.csv
for f in $fileList
do
name=`echo ${f} | xargs -n1 dirname | xargs -n1 basename`
line=`cat ${f} | awk -F',' '{print $2}' | tr '\n' ',' | sed -r 's/(.*),/\1\\n/'`
echo ${name},${line} >>anno_report.table.csv
done
#列合并所有文本
cat ${f} | awk -F',' '{print $1}' | tr '\n' ',' | sed -r 's/(.*),/\1\\n/' | xargs -i sed -i '1i\{}' anno_report.table.csv