当我这样做时
sed 1s/#text_to_be_replaced#/replacement_string/ filename
然后输出是预期的,但当我把它放在一个shell文件中 并且这样做
lineNumber=1
sed $lineNumbers/#text_to_be_replaced#/replacement_string/ filename
然后它没有按预期工作replacement_string
在text_to_be_replaced
上方插入一行。为什么会这样?
答案 0 :(得分:4)
应该是:
var eventTypes = [["write","write","write","write"],["write","write","read","write"]];
_.each(eventTypes,function(obj){
gettime(obj);
});
gettime=function(events){
var resultArray = [];
_.each(events,function(event){
if(event === "read"){
resultArray.push(makesqlquery(event));
}else{
resultArray.push({"time":current_time})
}
});
q.all(resultArray).then(function(finalResult){
insertIntoPostgreSQL(finalResult);
});
}
makesqlquery = function(event){
var deferred = q.defer();
sql.query("select time from events where eventtype ="+ event,
function(result,error){
if(error){
deferred.reject(error);
}else{
deferred.resolve({time:result.time});
}
});
return deferred.promise;
}