yank1
Yank terminal output to clipboard
Usage
yank [-1ilxv]
[-d
delim]
[-g
pattern]
[--
command
[argument ...]]
Overview
Read input from stdin and display a selection interface that allows a field to be selected and copied to the clipboard. Fields are either recognized by a regular expression using the -g option or by splitting the input on a delimiter sequence using the -d option, see DELIMITERS.
Using the arrow keys will move the selected field, see COMMANDS. Pressing the return key will invoke command and write the selected field to its stdin. The command defaults to xsel but could be anything that accepts input on stdin, see EXAMPLES.
The options are as follows:
-
-1 -
If only one field is recognized, select it and invoke command without displaying the selection interface.
-
-d delim -
All input characters not present in delim will be recognized as fields, see DELIMITERS.
-
-g pattern -
Use pattern to recognize fields, expressed as a POSIX extended regular expression.
-
-i -
Ignore case differences between pattern and the input.
-
-l -
Use the default delimiters except for space, see DELIMITERS.
-
-v -
Prints version.
-
-x -
Use alternate screen.
--command [argument ...]-
Use command with zero or more args as the yank command.
Commands
Ctrl-A|g-
Move selection to the first field.
Ctrl-C|Ctrl-D-
Exit without invoking the yank command.
Ctrl-E| G-
Move selection to the last field.
Ctrl-P/Ctrl-N|Left/Right|h/l-
Move selection to the left or right.
Ctrl-L-
Toggle between current and line delimiter, equivalent to the
-loption. Up/Down|j/k-
Move selection to the next or previous line.
Enter-
Exit using the selected field.
Delimiters
If the -d and -g options are omitted the following characters are recognized as delimiters by default:
- \f
-
form feed
- \n
-
new line
- \r
-
carriage return
- \s
-
space
- \t
-
horizontal tab
If the -d option is present space is not recognized as a delimiter.
Examples
Yank an environment variable key or value:
$ env | yank -d =
Yank a field from a CSV file:
$ yank -d \", <file.csv
Yank a whole line using the -l option:
$ make 2>&1 | yank -l
If stdout is not a terminal the selected field will be written to stdout and exit without invoking the yank command. Kill the selected PID:
$ ps ux | yank -g [0-9]+ | xargs kill
Yank the selected field to the clipboard as opposed of the default primary clipboard:
$ yank — xsel -b
Diagnostics
The yank utility exits 0 on success, and >0 if an error occurs.
Caveats
Recognizing fields enclosed in brackets requires ‘]’ to be present before ‘[’ in the argument given to the -d option, see re_format(7).
Releases
4 releases since Debian 3.1 (Sarge); the text changed 3 times.
-1 since Arch Linux 2026-11-01;
-d since Debian 10 (Buster);
-i since Debian 10 (Buster);
-l since Debian 10 (Buster);
-v since Debian 10 (Buster);
-x since Debian 10 (Buster).
--class until Debian 3.1 (Sarge);
--disable-crash-dialog until Debian 3.1 (Sarge);
--disable-sound until Debian 3.1 (Sarge);
--display until Debian 3.1 (Sarge);
--enable-sound until Debian 3.1 (Sarge);
--espeaker until Debian 3.1 (Sarge);
--file until Debian 3.1 (Sarge);
--g-fatal-warnings until Debian 3.1 (Sarge);
--gdk-debug until Debian 3.1 (Sarge);
--gdk-no-debug until Debian 3.1 (Sarge);
--geometry until Debian 3.1 (Sarge);
--gtk-debug until Debian 3.1 (Sarge);
--gtk-module until Debian 3.1 (Sarge);
--gtk-no-debug until Debian 3.1 (Sarge);
--gxid_host until Debian 3.1 (Sarge);
--gxid_port until Debian 3.1 (Sarge);
--help until Debian 3.1 (Sarge);
--name until Debian 3.1 (Sarge);
--no-xshm until Debian 3.1 (Sarge);
--sm-client-id until Debian 3.1 (Sarge);
--sm-config-prefix until Debian 3.1 (Sarge);
--sm-disable until Debian 3.1 (Sarge);
--sync until Debian 3.1 (Sarge);
--usage until Debian 3.1 (Sarge);
--version until Debian 3.1 (Sarge);
--xim-preedit until Debian 3.1 (Sarge);
--xim-status until Debian 3.1 (Sarge);
-? until Debian 3.1 (Sarge);
-f until Debian 3.1 (Sarge).