1. 程式人生 > >如何遍歷文件夾 取得文件名和首行記錄輸出到CSV文件

如何遍歷文件夾 取得文件名和首行記錄輸出到CSV文件

type china tput col ref nbsp 遍歷文件夾 如何 color

for x in `find -type f`; do sed -n "1{s,.*,${x##*/}\t&,p}" $x; done > output.csv

for x in `find -type f`; do sed -n "1{s/.*/${x##*/},&/p}" $x; done > output.csv

for x in `find -type f`; do sed -n "1{s/.*/${x:2},&/p}" $x; done > output.csv

Refer:http://bbs.chinaunix.net/thread-4152680-1-1.html

如何遍歷文件夾 取得文件名和首行記錄輸出到CSV文件