1

This works:

curl -Ls -o /dev/null -w %{url_effective} $URL | xargs printf "%s" > /dev/clipboard

whereas this doesn't:

curl -Ls -o /dev/null -w %{url_effective} $URL > /dev/clipboard

Why is that?

8
  • maybe as the curl output is seen as multiple items ? try ` > filename` and looks at its content.
    – matzeri
    Commented May 18, 2021 at 10:02
  • > filename did work; although I don't understand why the output is seen as multiple items (it's a URL). Thanks. Could you add this as an answer?
    – markvgti
    Commented May 18, 2021 at 10:15
  • If I capture the output using > filename, then cat filename > /dev/clipboard does work as expected...
    – markvgti
    Commented May 18, 2021 at 10:17
  • My guess: curl -Ls -o /dev/null -w %{url_effective} $URL exit with something else than success. Try curl -Ls -o /dev/null -w %{url_effective} $URL || echo -e "\nFAIL'. Anyway it shouldn't prevent clipboard update. Seems that curl is messing with fd.
    – Zilog80
    Commented May 18, 2021 at 10:29
  • @Zilog80 curl does print out both: the final URL and "FAIL"
    – markvgti
    Commented May 18, 2021 at 10:38

1 Answer 1

1

two possible solutions

curl -Ls -o /dev/null -w %{url_effective} $URL > filename
cat filename > /dev/clipboard

and

curl -Ls -o /dev/null -w %{url_effective} $URL | putclip

putclip is in

$ cygcheck -f /usr/bin/putclip
cygutils-extra-1.4.16-2

Not the answer you're looking for? Browse other questions tagged or ask your own question.