Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用shell拆分数据_Shell_Unix_Hadoop - Fatal编程技术网

使用shell拆分数据

使用shell拆分数据,shell,unix,hadoop,Shell,Unix,Hadoop,我是新手。我需要使用shell脚本获取运行和自动匹配计数之间的数据。因此,它可以作为半结构化数据进行处理。请指教 sed -n '/run/,/Automatic/ {//!p }' test.txt 这将打印run和Automatic之间的所有行(,)!从输出中删除行运行和自动匹配计数 这将打印run和Automatic之间的所有行(,)!从输出中删除行运行和自动匹配计数 使用sed-n'/run/,/Automatic/p'filename.txt | sed'1d$d'| sed'$d

我是新手。我需要使用shell脚本获取运行和自动匹配计数之间的数据。因此,它可以作为半结构化数据进行处理。请指教

sed -n '/run/,/Automatic/ {//!p }' test.txt
这将打印run和Automatic之间的所有行(,)!从输出中删除行运行和自动匹配计数

这将打印run和Automatic之间的所有行(,)!从输出中删除行运行和自动匹配计数


使用
sed-n'/run/,/Automatic/p'filename.txt | sed'1d$d'| sed'$d;s///g'
-应该清理数据(第一行、最后两行和开头的空格)

shell脚本-
split.sh

按以下方式运行任何文件,以在控制台和文件中获得输出:

输出将存储在
splitted.dat
文件中:

更新:

输出:


使用
sed-n'/run/,/Automatic/p'filename.txt | sed'1d$d'| sed'$d;s///g'
-应该清理数据(第一行、最后两行和开头的空格)

shell脚本-
split.sh

按以下方式运行任何文件,以在控制台和文件中获得输出:

输出将存储在
splitted.dat
文件中:

更新:

输出:


谢谢如果我需要以下输出。验证正确:32426(86.5%)良好匹配:2102(5.6%)良好前提部分:862(2.3%)暂定匹配:1039(2.8%)不良匹配:4(0.0%)多个匹配:7(0.0%)部分匹配:872(2.3%)国外地址:2(0.0%)不匹配:183(0.5%)谢谢!如果我需要以下输出。验证正确:32426(86.5%)良好匹配:2102(5.6%)良好前提部分:862(2.3%)暂定匹配:1039(2.8%)不良匹配:4(0.0%)多个匹配:7(0.0%)部分匹配:872(2.3%)国外地址:2(0.0%)不匹配:183(0.5%)
#!/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
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%)