a.txt 内容如下 #this is 0 context abc ddd #this is 1 context xxx xxxx xxxxx #this is 2 context 1213
上面的 a.txt ,我想变成三个文件,靠#分割,变成 a_0.txt abc ddd
a_1.txt xxx xxxx xxxxx
a_2.txt 1213
1
hailongs OP 我去。。。
#this is 0 context abc ddd #this is 1 context xxx xxxx xxxxx #this is 2 context 1213 |
2
hailongs OP a_0.txt
abc ddd a_1.txt xxx xxxx xxxxx a_2.txt 1213 |
3
cute Dec 19, 2016
sed 's/ #/\n/g' a.txt
|
5
slixurd Dec 19, 2016
用 AWK 吧= =
awk '{if( $0~/^#/) x++ ;else print > "txt"x}' file |
7
tftk Dec 19, 2016
echo $a | tr '#' '\n' | while read line;do echo $line > youfile.txt;done
|