How To Use Pbcopy And Pbpaste Commands On Linux - OSTechNix

Discover how to replicate macOS pbcopy and pbpaste commands functionality in Linux using Xclip and Xsel programs.

OSTechNix

Attempting to paste an empty pb happens so rarely it feels like a machine freeze.

#macOS #pbpaste #cmdv #pasteboard

I regularily use #pbcopy and #pbpaste shell commands on #MacOS. They are great to quickly process text. E.g. this formats JSON in clipboard and puts it back to clipboard:

$ pbpaste | jq | pbcopy

or this find the number of unique lines containing the word foo in file.txt:

$ grep foo file.txt | sort | uniq -c | pbcopy

PS: you can use `xmllint --format -` to format XML rather than #jq for JSON