2

like in subject. I'm curious how to get value in bash script from Clipboard.

I would like to write sh script which after execution will take value from Clipboard (Ctrl+c), but I haven't found how to get this value in the script.

Any idea folks, thanks :)

Robert
  • 3,790
  • 1
  • 27
  • 46
  • [Pipe to/from the clipboard in Bash script](https://stackoverflow.com/q/749544/608639), [Paste clipboard content into a variable in bash using xclip](https://stackoverflow.com/q/23046580/608639), [Copy a string to clipboard from Mac OS command line](https://stackoverflow.com/q/39692617/608639), [Copy pure text from clipboard using AppleScript](https://stackoverflow.com/q/15190868/608639), [shell script output to clipboard](https://stackoverflow.com/q/4023703/608639), [Is there an Environment Variable that contains the clipboard contents?](https://stackoverflow.com/q/1064762/608639), etc. – jww Apr 14 '18 at 03:53

1 Answers1

7

On Mac OS, pbcopy/pbpaste:

echo "Set the clipboard" | pbcopy

clipboard="$(pbpaste)"

On Linux with X11, xclip.

echo "Set the clipboard" | xclip

clipboard="$(xclip -o)"
Dan
  • 4,312
  • 16
  • 28