Shell use clipboard to copy and paste

目录
  • copy text file content to clipboard
    pbcopy < file.txt

  • copy command stdout to clipboard
    ps aux | pbcopy

  • copy text
    echo text | pbcopy

  • paste from clipboard to file
    pbpaste > file.txt

filter string
pbpaste | grep "hello" > file2.txt

  • echo text from clipboard
    echo | pbpaste

Reference