Re: [請問] 許多文字檔只抓其中一行?

作者: windincloud (虹霓之戀)   2011-01-27 18:09:17
若用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

Links booklink

Contact Us: admin [ a t ] ucptt.com