它可以使用索引和子串命令将此代码转换为ruby,使用类似的sintax转换为awk?

时间:2017-04-04 22:15:46

标签: ruby linux awk

我知道是否可以生成使用ane的ruby代码

像这样

ruby​​ -a -F'Name“:” - '-ne

这是我的awk代码

     awk -v OFS='"' -v   FS='Name": "'     '{ i2 = index($4, "\""); print  ";" substr($4, 0, i2) }'   sumacomando

我需要知道是否可以使用ruby one liner或ruby,这是有限的这项任务

只需要知道ruby中是否存在索引和子字符串的类似选项或者如果这个选项非常不同

基本上我只需要知道ruby在这个例子中是否具有类似awk的功能

请帮帮我

1 个答案:

答案 0 :(得分:0)

我解决了它:

0 0 0 0 0 0 1 0 1 0 0 0 7 0 0 7 0 0 0 1 0 1 0 0 
0 0 0 0 0 0 0 0 0 3 1 0 0 0 0 0 0 1 3 0 0 0 0 0 
0 0 0 0 0 0 0 5 0 2 0 1 0 1 1 0 1 0 2 0 5 0 0 0 
0 0 0 0 0 0 1 0 0 2 0 2 0 1 1 0 2 0 2 0 0 1 0 0 
0 0 0 0 0 0 0 2 0 1 0 0 1 1 1 0 0 0 2 0 2 0 0 0 
0 0 0 0 0 0 4 0 0 1 1 1 1 1 1 1 1 0 0 2 0 3 0 0 
0 0 0 0 0 0 0 0 1 0 1 1 1 1 1 1 0 1 2 0 0 0 0 0 
0 0 0 0 0 0 0 4 0 1 1 1 1 1 1 1 1 0 1 0 1 0 0 0 
0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 0 0 0 0 0 1 0 0 0 
0 0 0 0 0 0 1 1 1 1 1 1 1 1 0 1 2 0 2 0 1 0 0 0 
0 0 0 0 0 0 0 1 1 1 1 1 1 0 2 0 0 0 2 0 2 0 0 0 
0 0 0 0 0 0 1 1 1 1 1 1 0 2 0 0 2 2 0 1 0 0 0 0 
0 0 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 3 0 1 1 1 0 0 1 0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 5 1 1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