我是新的shell脚本。我需要使用shell脚本在运行和自动匹配计数之间获取数据。以便它可以作为半结构化数据进行处理。请咨询使用shell拆分数据
0
A
回答
1
使用sed -n '/run/,/Automatic/p' filename.txt|sed '1d;$d'|sed '$d;s/ //g'
- 应该清理(以年初1号线,2分最后几行和空格)数据
shell脚本 - split.sh
:
#!/bin/bash
sed -n '/run/,/Automatic/p' $1|sed '1d;$d'|sed '$d;s/ //g'
跑了下面的任何文件在控制台和文件中输出:
shell> ./split.sh test.txt |tee splitted.dat
United Kingdom: 21/09/2012
Started: 08/02/2013 16:04:44
Finished: 08/02/2013 16:21:23
Time to process: 0 days 0 hours 16 mins 39 secs
Records processed: 37497
Throughput: 135124 records/hour
Time per record: 0.0266 secs
输出将被存储在文件splitted.dat
:
shell> cat splitted.dat
United Kingdom: 21/09/2012
Started: 08/02/2013 16:04:44
Finished: 08/02/2013 16:21:23
Time to process: 0 days 0 hours 16 mins 39 secs
Records processed: 37497
Throughput: 135124 records/hour
Time per record: 0.0266 secs
shell>
更新:
#!/bin/bash
# p - print lines with specified conditions
# !p - print lines except specified in conditions (opposite of p)
# |(pipe) - passes output of first command to the next
# $d - delete last line
# 1d - delete first line (nd - delete nth line)
# '/run/,/Automatic/!p' - print lines except lines between 'run' to 'Automatic'
# sed '1d;s/ //g'- use output from first sed command and delete the 1st line and replace spaces with nothing
sed -n '/run/,/Automatic/!p' $1 |sed '1d;s/ //g'
输出:
Verified Correct: 32426 (86.5%)
Good Match: 2102 (5.6%)
Good Premise Partial: 862 (2.3%)
Tentative Match: 1039 (2.8%)
Poor Match: 4 (0.0%)
Multiple Matches: 7 (0.0%)
Partial Match: 872 (2.3%)
Foreign Address: 2 (0.0%)
Unmatched: 183 (0.5%)
1
相关问题
- 1. 拆分数据
- 2. 拆分数据
- 3. 拆分数据
- 4. 拆分数据
- 5. 将数据拆分为一列,并使用拆分数据更新新列
- 6. 拆分数据为使用CSS
- 7. 拆分数据表
- 8. 拆分数据帧
- 9. 拆分和分析数据
- 10. 使用jquery拆分数组?
- 11. * ngfor数组拆分数据
- 12. 拆分和非拆分数据框分为四部分
- 13. 使用ffdfdply拆分数据并获得拆分中每个id的特征
- 14. 拆分一列数据
- 15. 如何拆分数据框?
- 16. 拆分python数据包?
- 17. 拆分数据文件
- 18. 如何拆分数据与[/ - ]
- 19. 一列的拆分数据
- 20. 拆分SAS数据集
- 21. 数据库:拆分表
- 22. 按列拆分数据帧
- 23. 拆分URL中的数据?
- 24. 导轨 - 数据库拆分
- 25. 拆分数据未在FF
- 26. 拆分数据帧dataframes
- 27. 拆分和提取数据
- 28. 拆散分层数据
- 29. 拆分数据帧由
- 30. 拆分数据为列
谢谢!验证正确:32426(86.5%) 适合:2102(5.6%) 良好前提部分:862(2.3%) 暂时匹配代码:1039(2.8%) 不符合:4(0.0%部分匹配:872(2.3%) 外地址:2(0.0%) 无与伦比:183(0.5%) 多个匹配项:7(0.0%) – Holmes