使用xclip将剪贴板内容粘贴到bash中的变量中 [英] Paste clipboard content into a variable in bash using xclip

查看:79
本文介绍了使用xclip将剪贴板内容粘贴到bash中的变量中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道此命令会将剪贴板内容粘贴到文件中:

I know this command will paste the clipboard contents into a file:

xclip -out -selection clipboard >> file.txt

如果我想将剪贴板内容粘贴到像字符串这样的变量中,该怎么办?

If I want to paste clipboard content into a variable like a string what do I do?

推荐答案

要将命令的输出分配给变量,可以使用命令替换:

To assign the output of a command to a variable, you can use command substitution:

myvar=$( command )
echo "$myvar"

这篇关于使用xclip将剪贴板内容粘贴到bash中的变量中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆