如果你有一个
mail.txt
$ cat mail.txt<html> mail A</html><html> mail B</html><html> mail C</html>
跑来
csplit分裂
<html>
$ csplit mail.txt '/^<html>$/' '{*}' - mail.txt => input file - /^<html>$/ => pattern match every `<html>` line - {*} => repeat the previous pattern as many times as possible
检查输出
$ lsmail.txt xx00 xx01 xx02 xx03
如果你想这样做
awk
$ awk '/<html>/{filename=NR".txt"}; {print >filename}' mail.txt$ ls1.txt 5.txt 9.txt mail.txt
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)