作者windincloud (當你孤單會想起誰)
看板RegExp
標題Re: [請問] 許多文字檔只抓其中一行?
時間Thu Jan 27 18:09:17 2011
若用linux-like 系統
可以寫 shell script
#!/bin/bash
dir="your text file dir"
output="out.o"
for i in $dir/*
do
#get file name
filename=${i##*/}
#remove 附檔名
filename=${name%.*}
#output filename into $output
echo $filename >> $output
#get the line which in last fifth.
tail -n 5 $i | head -n 1 >> $output;
done
ps. windows下可灌cygwin
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.109.183.71