yank man page
yank — yank terminal output to clipboard
- Yank using the default delimiters (\f, \n, \r, \s, \t):
sudo dmesg | yank
- Yank an entire line:
sudo dmesg | yank -l
- Yank using a specific delimiter:
echo hello=world | yank -d =
- Only yank fields matching a specific pattern:
ps ux | yank -g "[0-9]+"
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(1) but could be anything that accepts input on
stdin, see Examples.
The options are as follows:
- -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.
Ignore case differences between pattern and the input.
Use the default delimiters except for space, see Delimiters.
Use alternate screen.
- -- command [argument ...]
Use command with zero or more args as the yank command.
- 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.
- Up/Down | j/k
Move selection to the next or previous line.
Exit using the selected field.
If the -d and -g options are omitted the following characters are recognized as delimiters by default:
If the -d option is present space is not recognized as a delimiter.
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
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
The yank utility exits 0 on success, and >0 if an error occurs.
Anton Lindqvist <firstname.lastname@example.org>