Use the built-in pbcopy utility:
cat filename.txt | pbcopy
Replace filename.txt with the file you want to copy.
Use xclip to copy to the system clipboard:
xclip -selection clipboard < filename.txt
Or with cat:
cat filename.txt | xclip -selection clipboard
Install with:
sudo apt install xclip
Use wl-copy if on Wayland:
wl-copy < filename.txt
Install with:
sudo apt install wl-clipboard
In PowerShell:
Get-Content filename.txt | Set-Clipboard
Or using WSL:
cat filename.txt | clip.exe