我有以下功能,它解密 base64 文件并将其写入 txt 文件。但是,我希望它输出到标准输出,而不是写入文本文件。你能建议我们如何做到这一点吗
CipherOutputStream cos = new CipherOutputStream(os, cipher);
doCopy(is, cos);
}
public static void doCopy(InputStream is, OutputStream os) throws IOException {
byte[] bytes = new byte[64];
int numBytes;
while ((numBytes = is.read(bytes)) != -1) {
os.write(bytes, 0, numBytes);
}
Run Code Online (Sandbox Code Playgroud)
因此,与其 os.write 将流写入 txt 文件,不如将其写入 stdout。
我们如何使用 sed 获取 " Install ID:
" 和后面第一个空格之间的 4 个字符XKCD
,基本上我想XKCD
从中提取 " " 字符串
Install ID: XKCD (8426200,8179503)
Run Code Online (Sandbox Code Playgroud)
我尝试使用 -
echo "Install ID: XKCD (8426200,8179503)" | sed -n 's/^.*ID:\(.*\)*$/\1/p'
Run Code Online (Sandbox Code Playgroud)
但这给了我“ XKCD (8426200,8179503)
”而不是仅仅XKCD
。我无法弄清楚如何处理空间部分。