FlossDoc: 請協力 GPLv3 的中文翻譯工作。

在 Shell script 中存取剪貼簿

FlossDoc,自由中文開源知識庫

Jump to: navigation, search

把命令的輸出複製至剪貼簿可以使用命令「xclip -selection clipoard」,例如:

cat /etc/hosts | xclip -selection c

複製至第一選取 (Primary Selection) 可以使用命令「xclip -selection primary」,例如:

uname -a | xclip -selection p

取得剪貼簿的內容:

xclip -o -selection c

取得第一選取 (Primary Selection) 的內容:

xclip -o -selection p

以下是一個小程式用 gwget 下載剪貼簿中的 URL:

#!/bin/sh

SELECT=`xclip -o`

case "$SELECT" in
	http*|ftp*|file*) gwget "$SELECT" ;;
	*) gwget ;;
esac

外部資料

Personal tools