macos – Using curl to download image, and copy to the PNG to the clipboard

Spread the love

I’m using curl and grep to get the URL of an image, after that I’d like to download the image itself, and copy it to the clipboard directly, rather than saving it to the disk temporarily before. I’m puzzled that the output doesn’t seem to work. It only gives me “text” rather than the image itself. Here’s the command I have so far:

curl -s | grep -oE "src="[^"]+'" | sed -E "s/src="([^"]+)'/1/" | xargs curl -s | pbcopy

If there’s an easier solution to this, please let me know. The command is built around the idea that the website here has only ONE img tag.

Author: Dhanraj7978

Leave a Reply

Your email address will not be published. Required fields are marked *