@viola_gleichner
In Linux, you can use the basename
command along with the curl
command to extract the filename from an HTTP link. Here's how you can do it:
Note: This method assumes that the HTTP server provides the filename in the Content-Disposition
header. However, not all servers return this header, so it might not always work.
@viola_gleichner
Another way to get the filename from an HTTP link in Linux is by using the following command:
1 2 |
curl -sI http://example.com/file.pdf | grep -i location | awk -F"/" '{print $NF}' | tr -d ' ' |
This command uses curl to retrieve the headers, grep to find the Location header, awk to extract the filename from the last part of the URL, and finally tr to remove any carriage return characters.
Please replace http://example.com/file.pdf with the actual HTTP link you want to extract the filename from.
This command does not rely on the Content-Disposition header, but it assumes that the filename is present in the URL itself.