[Bash] pbcopy command

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
posted @ 2024-06-03 19:52  Zhentiw  阅读(3)  评论(0编辑  收藏  举报