当前位置:网站首页>Write one file to the marked location of another file

Write one file to the marked location of another file

2022-06-25 15:42:00 Never, calm down

Will file A Write to file B The location of the identifier

Ideas

sed -i ‘’ ‘10r file-a.js’ ./file-b.js
lookup identifier grep -n -r insertModuleFile ./file-b.js | awk -F “{ print $2 }”

Realization

file A

function ModuleFile(){
    
	//  This is a test file 
}

file B

function getModuleFile(){
    
	// insertModuleFile
}

Expected results

function getModuleFile(){
    
	// insertModuleFile
function ModuleFile(){
    
	//  This is a test file 
}
}

Script

sed -i '' "$(grep -n -r insertModuleFile ./file-B.js | awk -F : '{ print $2 }')r ./file-A.js" ./file-B.js

Script

sed -i '' "$(grep -n -r insertModuleFile ./worklet-process-sed.js | awk -F : '{ print $2 }')r ./dist/Math.js" ./worklet-process-sed.js
原网站

版权声明
本文为[Never, calm down]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/176/202206251508237085.html