Sometimes you just want to copy or paste a file directly from the terminal.
Mac users have simple single commands called pbcopy
and pbpaste
.
We have the slightly less elegant xsel
or xclip
To be able to use pbcopy
and pbpaste
just like Mac terminal users, all we have to do it is :
- first install xclip in case you do not already have it
sudo apt-get install xclip -y
- then create alias commands which allow you to use
pbcopy
andpbpaste
as shortcuts
alias pbcopy='xclip -selection clipboard'
alias pbpaste='xclip -selection clipboard -o'
Now you can just copy the contents of a file to clipboard withpbcopy filename.txt
Or you can paste contents of clipboard to a file withpbpaste > filename.txt