Copy & Paste in Terminal

Mac provides the command line for copy and paste, useful for some tasks.

reference link:http://osxdaily.com/2007/03/05/manipulating-the-clipboard-from-the-command-line/

Copy

copy the content of the file

1
pbcopy < file.txt

Now the content is in clipboard, ready to be pasted.

you can use pipe to combine command such as find, grep, awk and cut to filter and augment data.

for example:

1
2
echo "this is a demo" | pbcopy
docker images | grep "iis-" | pbcopy

Paste

Simply run this command:

1
pbpaste

Redirect content to a file:

1
pbpaste > file.txt
1
pbpaste | grep "xxx"
0%