
www.Google.org||o||srScSG2C5tg=||o||bngwqfarhansingla.it||o||4sQVj09gpls=||o||ngascash||o||||o||ms-bronze.com.br||o||||o||
我想在1.txt中只移动一个字段,在not_1.txt中只移动一个字段.我使用以下命令:
sed 's/\(||o||\)\+$//g' sample.txt | awk -F '[|][|]o[|][|]' '{if (NF == 1) print > "1.txt"; else print > "not_1.txt" }' 问题是它不是原始线而是移动线.
我得到的输出是(not_1.txt):
td@the-end.org||o||srScSG2C5tg=||o||bnmerba01@tiscali.it||o||4sQVj09gpls=
1.TXT:
ngasms-insIDe@bol.com.br
如您所见,原始线条已被修改.我不想修改这些行.
任何帮助将受到高度赞赏.
awk -F '[|][|]o[|][|]' \'{ c = 0; for (i=1; i<=NF; i++) if ($i != "") c++; print > (c == 1? "1" : "not_1")".txt" }' sample.txt 结果:
$head 1.txt not_1.txt ==> 1.txt <==ngascash||o||||o||ms-bronze.com.br||o||||o||==> not_1.txt <==www.Google.org||o||srScSG2C5tg=||o||bngwqfarhansingla.it||o||4sQVj09gpls=||o||总结
以上是内存溢出为你收集整理的linux – 使用awk按行数将行移动到文件中全部内容,希望文章能够帮你解决linux – 使用awk按行数将行移动到文件中所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)