惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

F
Fortinet All Blogs
美团技术团队
T
Tenable Blog
大猫的无限游戏
大猫的无限游戏
Schneier on Security
Schneier on Security
S
Schneier on Security
博客园_首页
C
Cyber Attacks, Cyber Crime and Cyber Security
I
Intezer
T
Tailwind CSS Blog
GbyAI
GbyAI
C
CERT Recently Published Vulnerability Notes
博客园 - 【当耐特】
IT之家
IT之家
G
Google Developers Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
P
Privacy International News Feed
Vercel News
Vercel News
Cyberwarzone
Cyberwarzone
N
News and Events Feed by Topic
Application and Cybersecurity Blog
Application and Cybersecurity Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
The Register - Security
The Register - Security
人人都是产品经理
人人都是产品经理
Cisco Talos Blog
Cisco Talos Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Project Zero
Project Zero
V
V2EX
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
月光博客
月光博客
Hacker News - Newest:
Hacker News - Newest: "LLM"
WordPress大学
WordPress大学
L
LangChain Blog
阮一峰的网络日志
阮一峰的网络日志
MongoDB | Blog
MongoDB | Blog
F
Full Disclosure
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
N
News and Events Feed by Topic
G
GRAHAM CLULEY
H
Hacker News: Front Page
Forbes - Security
Forbes - Security
H
Heimdal Security Blog
L
LINUX DO - 最新话题
L
Lohrmann on Cybersecurity
Apple Machine Learning Research
Apple Machine Learning Research
Help Net Security
Help Net Security
C
Cybersecurity and Infrastructure Security Agency CISA
Recent Announcements
Recent Announcements
C
Cisco Blogs
L
LINUX DO - 热门话题

Bash

Linux bash 脚本监控和重启一个守护进程 - V2EX 有个脚本代码的问题 Bash Script 代码比较,你认为哪个更加容易理解? 有使用 kitty 当日常终端的老哥吗? - V2EX 在输入命令时,自动调用 fzf 进行模糊匹配 使用 shell 的 bash -c "functions"时,是不是所有相关的函数都得声明出来? shell 比较浮点数大小的问题,顺便吐槽以下 shell - V2EX bash-completor:声明式编写 Bash 补全脚本 - V2EX sudo 改用 pkexec 的问题 - V2EX sed 如何查找替换反斜杠 - V2EX lobash 发布 v0.5.0 版本 - V2EX 为什么这样写无法连接(join)数组各项? - V2EX 如何使用 awk 打印 nginx 404 日志的目录 - V2EX 请教一下 shell 里使用 jq 处理 json 应该怎么写 - V2EX 求一个 wsl2 ubuntu20.04 的默认 /etc/bash.bashrc - V2EX 如何让 bash 的补全 popup 显示 - V2EX 如何去除 Bash variable expansion 后加的单引号? - V2EX 初学者写了个 bash 脚本,求大佬点评 - V2EX tar 使用管道的困惑 - V2EX 如何获取命令标准输出到变量里并保留颜色?或者能不能一边输出一边赋值或判断。 - V2EX 请问如何在 alias 命令里传递参数? - V2EX Bash 下如何优雅地临时在后台运行程序并易于管理? - V2EX shell tr -cd 匹配字符串问题 - V2EX shell 中的 import 能不能支持 as 或 alias 类似功能 - V2EX Shell 多个文本间隔追加的方法 - V2EX 生产服务器集群被黑了,帮看看这个脚本 - V2EX 如何实现一个符合规范的 shell? - V2EX 请教下如何检测文件是否存在 - V2EX bash 里面有 io 多路复用吗? - V2EX 闲的蛋疼,用 shell 写了个拓扑排序。。。 - V2EX echo '1 2'|awk "{print $2}"的输出为什么是 1 2 - V2EX Shell 中冒号变成了斜线 - V2EX 大家觉得 shell 如何呢? - V2EX 如何让 ls 默认带--group-directories-first 选项 - V2EX shell 脚本用 expect 输入密码,密码带有{}导致 expect 报错 - V2EX 询问一个正则表达式,请大家帮忙 - V2EX 请教一个 bash 的问题 - V2EX 请教 Shell 空字符串数组的问题 - V2EX 统计一下,如果你在用 bash,用什么版本号的 bash? - V2EX sh 可以运行后执行一段脚本吗? bash 是可以的。 - V2EX bash shell history search - V2EX Shell 给变量的赋值里带 $ 要怎么写? - V2EX [求助] shell 处理 yaml - V2EX 今天想合并文件写出个递归。。。 - V2EX 啊,我中毒了 - V2EX 寻一段 shell 来实现自动填写 ssh 登录密码 - V2EX 秀一下原生的 “终端.app”(bash) - V2EX # [求助] 用 curl 抓取一个网站,网站有很多分页,但不论怎么指 page=[2-100],抓取的都只是 page=1 的内容... - V2EX 请问这段 shell 代码有设么问题吗 - V2EX
请教一下,怎么把向终端输入的内容重定向一份到文件? - V2EX
tuduweb · 2021-12-21 · via Bash

这是一个创建于 1636 天前的主题,其中的信息可能已经有所发展或是发生改变。

类似于使用node | tee out.txt可以把 node 中输出的内容不仅输出到屏幕终端,还可以输出到文件out.txt

那怎么样做才能把不影响向终端中正常输入内容,同时把输入的内容保存一份到文件中,作为记录呢?

是要对/dev/stdin动手脚吗?

RTRT 谢谢各位了!

andyfan

1

andyfan      2021 年 12 月 21 日 via Android

有一个命令叫 history

thedrwu

2

thedrwu      2021 年 12 月 21 日 via Android

tee in.txt | node

tuduweb

3

tuduweb      2021 年 12 月 21 日

@andyfan 这个我试了,但好像它没办法获取在程序中的输入呀。比如可以获取在`node`中的输入信息吗…

lululau

5

lululau      2021 年 12 月 21 日

tee out.txt | node

另外,虽然标准 IO 默认指向终端,但是它和终端不是一个概念,标题应该把终端改为标准输入

tuduweb

6

tuduweb      2021 年 12 月 21 日

@lululau
```
(base) ➜ ~ tee out.txt | node
let a = 1
let b = 2
```
但是这样阻塞了 node 的交互信息输出了,有什么办法吗。…

lululau

7

lululau      2021 年 12 月 21 日

brew install ttyrec

man ttyrec

man ttyplay

sisylocke

8

sisylocke      2021 年 12 月 21 日

不行的,在 stdout 进程结束前终端不能读取 stdin ,你需要的是 readlineSync 之类的工具。

zhlxsh

9

zhlxsh      2021 年 12 月 21 日 via iPhone

你要做的原本的事情是什么,我觉得有可能通过其他方法去完成你的要求

lululau

10

lululau      2021 年 12 月 21 日

其实 tee out.txt | node 这个方法是对的,你说的阻塞了 node 的交互信息输出,是因为 node 判断了如果标准输入不是 tty 则默认启用 script mode ,可以加 -i 参数强制 interactive mode

tee out.txt | node -i

hsfzxjy

11

hsfzxjy      2021 年 12 月 21 日 via Android

你是要 script 命令吧

tuduweb

12

tuduweb      2021 年 12 月 21 日

@zhlxsh 我要做的是,根据用户在终端中的输入,来判断用户是否完成了某些步骤。
比如我想判断用户在 gdb 调试器中,是否根据流程(教程)输入了某些控制指令,我个人想到的简单的方式是判断输入。

tuduweb

14

tuduweb      2021 年 12 月 21 日

@hsfzxjy 谢谢!刚试了一下,这样会把所有的按键操作都给记录了,删除啊这些等等,跟想要的还是不太一样。