Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Paste clipboard content into a variable in bash using xclip

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?

like image 936
Do Thanh Tung Avatar asked Jan 11 '23 19:01

Do Thanh Tung


1 Answers

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

myvar=$( command )
echo "$myvar"
like image 150
user000001 Avatar answered Jan 17 '23 21:01

user000001