例子:
1234567891011
// 从 coscmd info <fileId> 命令的结果中抽取 Last-Modified 时间const { spawn } = require('child_process');const info = spawn('coscmd', ['info', cosId]);info.stdout.on('data', (data) => { data = data.toString(); let i = data.indexOf("Last") let j = data.indexOf("GMT") let s = data.substring(i + 22, j) + "GMT" console.log(new Date(s))})
Node.js官网链接