shell-转义 - shell中单引号怎么转义
本文介绍了shell-转义 - shell中单引号怎么转义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
const exec = require('child_process').exec;
exec('cat /dev/urandom |od -x|tr -d ' '|head -n 1', (error, stdout, stderr) => {
if (error) {
console.error(`exec error: ${error}`);
return;
}
console.log(`stdout: ${stdout}`);
console.log(`stderr: ${stderr}`);
});
上面的shell命令中单引号怎么转义?加反斜杠不行
解决方案
换双引号?exec("cat /dev/urandom |od -x|tr -d ' '|head -n 1", (error, stdout, stderr) => {
这篇关于shell-转义 - shell中单引号怎么转义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文