pbcopy
is a command-line utility available on macOS that allows you to copy the output of a command directly to the clipboard. It can be very handy for quickly copying text or the results of commands to use elsewhere.
# Copy Text to Clipboard:
echo "Hello, World!" | pbcopy
# Copy the Contents of a File to Clipboard:
cat filename.txt | pbcopy
# Copy the Output of a Command to Clipboard:
ls -l | pbcopy
# Copy Multiline Text to Clipboard:
echo -e "Line 1\nLine 2\nLine 3" | pbcopy
# Copy the Results of a Search to Clipboard:
grep "search_term" filename.txt | pbcopy
# Copy the git diff
git diff | pbcopy
标签:echo,Clipboard,command,diff,Copy,Bash,pbcopy
From: https://www.cnblogs.com/Answer1215/p/18229524