Sed:在随机文本之前插入文本

时间:2018-08-21 01:38:49

标签: linux awk sed grep

使用sed更改此设置时遇到问题:

CASE

对此:

var going = 0;
onkeydown = onkeyup = function(e){    
 e = e || event; // to deal with IE
 mapDown[e.keyCode] = e.type == 'keydown';
 mapUp[e.keyCode] = e.type == 'keyup';
  if(going==0){
    if(mapDown[80] && mapDown[81]) {
       going = 1;
       timer = setTimeout(runTrial, 15000);
     }; // run the function runTrial() if the keys are held down for the requisite period
  } else if(going==1){
     if (mapUp[80] || mapUp[81]) {
      going = 0;
      clearTimeout(timer);
      keyUpFunc(); // stop the timer and run the function keyUpFunc() if either of the keys are released too early
     }
  }
}

runTrial = function(){
 going = 0; //This just resets the going value for the next trial. It may not be necessary if you just store going as a local variable and reset it at the start each time. 
 console.log("all done"); // replace this with the correct function.
}

能不能给我指出正确的方向?

非常感谢您。

最诚挚的问候,

1 个答案:

答案 0 :(得分:0)

那又怎么样:

使用2次迭代。测试它:

echo 'script_summary("Short random text");' | sed -e 's/script_summary("\(.*\)");/script_tag(name:"text", value:"\1");/'
echo 'script_id(@12345);' | sed -e 's/script_id(\(@[0-9]\+\));/script_oid("1.3.6.1.4.1.25623.1.0.\1");/'

因此您可能希望将其与 sed -i -e <regex1> <file> sed -i -e <regex2> <file>

cat <file> | sed -e <regex1> | sed -e <regex2>

取决于文件的大小以及您要使用的文件。