I want to download a file using
curl to a temporary directory with the appropriate extension.
Currently I do something like this:
tmp="$(mktemp -t 'curl')" curl -o "$tmp" http://example.com/generate_image.php?id=44 file -b --mime-type "$tmp"
This will print the mime-type of the downloaded file, but how do I map these to extensions?
As you can see I can't just extract the "extension" of the url as that would give
.php instead of
I know there isn't a one-to-one map between mime-types and file extensions but it should handle normal file extensions.