Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@agumonkey
Created November 17, 2014 13:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agumonkey/b85cef0874822c470cc6 to your computer and use it in GitHub Desktop.
Save agumonkey/b85cef0874822c470cc6 to your computer and use it in GitHub Desktop.
curl wrapper to only pipe text mime type to stdout, the rest to the filesystem
#!/usr/bin/env sh
case $(curl -sLI $1 | grep -i content-type) in
*text*) echo "curl $1"
;;
*) echo "curl $1 > $(basename $1)"
;;
esac
@agumonkey
Copy link
Author

tests

$ ./kurl google.com
curl google.com

$ ./kurl https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.17.3.tar.xz
curl https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.17.3.tar.xz > linux-3.17.3.tar.xz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment