Re: [請問] 許多文字檔只抓其中一行?
看板RegExp (正規表示式 Regular Expression)作者windincloud (當你孤單會想起誰)時間14年前 (2011/01/27 18:09)推噓0(0推 0噓 0→)留言0則, 0人參與討論串2/2 (看更多)
若用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
討論串 (同標題文章)
完整討論串 (本文為第 2 之 2 篇):
RegExp 近期熱門文章
PTT數位生活區 即時熱門文章