如何从终端读取隐藏的输入并将其管道到另一个命令
我希望能够在终端中牢固地键入文本,然后将其置于另一个命令中:
- 在您键入键入时,在终端历史记录中不记录
- 下来,它
- 不会在任何文件或环境变量中记录
- 在最短的时间内记忆中,
理想情况下:
- 使用 : Linux上的常用工具
- 易于使用,因为
echo
- 不必创建任何脚本/文件,
- 可以将
非安全输入的示例输送到其他命令示例
echo "secret" | wc -c
任何我想要的
read -s | wc -c
:基本上就像如何将密码输入到sudo
和类似。
我的用例
echo "secret" | gpg --encrypt --armor -r 1234567890ABCDEF | xclip
我正在寻找一种在上面点上提到的限制的方法。知道我正在寻找的不存在也是我会接受和标记的答案。
我从接受的答案中创建了别名
alias secnote="{ read -s; printf %s $REPLY; } | gpg --encrypt --armor -r 123467890ABCDEF | pbcopy"
I would like to be able securely type text in terminal and pipe it to another command to:
- Not be recorded in terminal history
- Be hidden as you type it
- Not be recorded in any file or environmental variable
- Be in memory for shortest possible time
Ideally:
- Using commonly installed tools on linux
- Easy to use as
echo
- Not having to create any scripts/files
- Can be piped to other commands
Example of non secure input
echo "secret" | wc -c
Almost what I want:
read -s | wc -c
Basically the same way how you input password to sudo
and similar.
My use case
echo "secret" | gpg --encrypt --armor -r 1234567890ABCDEF | xclip
I am looking for a way with restrictions I mentioned in points above. Knowing that what I am looking for doesn't exist is also an answer I will accept and mark.
I created alias from accepted answer
alias secnote="{ read -s; printf %s $REPLY; } | gpg --encrypt --armor -r 123467890ABCDEF | pbcopy"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是您想实现的目标吗?
或者您想要这样的单线:
如果定义一个别名:
那么您可以做
readp | WC -C
Is this what you wanted to achieve ?
Or you want one-liner like this :
If you define an alias :
then you can do
readp | wc -c