Filename output in curl


Login or Register to Reply

 
Thread Tools Search this Thread
# 1  
Filename output in curl

How can I get the name of the default output filename from curl using the argument -O?



Using -o one can choose a filename. I want to get the name of the original file, but don't understand how to get it.


Code:
curl -o filename http://www.website.com

curl -O http://www.website.com

The only way I know is an insufficient one using the last changed file with the command ls -lat
# 2  
Not sure what keeps you from trying what you already have in your post. What be its result? man curl (linux):
Quote:
-O/--remote-name
Write output to a local file named like the remote file we get. (Only the file part of the remote file is used, the path is cut off.)
The remote file name to use for saving is extracted from the given URL, nothing else.
Consequentially, the file will be saved in the current working directory. If you want the file saved in a different directory, make sure you change current working directory before you invoke curl with the -O/--remote-name flag!
You may use this option as many times as the number of URLs you have.

--remote-name-all
This option changes the default action for all given URLs to be dealt with as if -O/--remote-name were used for each one. So if you want to disable that for a specific URL after --remote-name-all has been used, you must use "-o -" or --no-remote-name. (Added in 7.19.0)
# 3  
I want to extract the name itself to a variable. The -O option doesn't do that. I can't attach the name to a variable because I don't know it.


I'm not sure if the ls -lat is a good way.
# 4  
How about

Code:
curl -vO http://www.website.com/index.php |& grep GET

Make sure you specify a remote filename to avoid receiving an error.
Login or Register to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Extracting urls from curl output
jozo95
Hello. I use curl to fetch a website, then, I want to extract the URLs from this curls output. I tried both sed and grep, but couldnt figure it out. Ive tried : sed -n 's/href="\(*\).*/\1/p' results.txt and grep -o grep -o '<a href="http://*.*.*/*">' results.txt. What pattern...... Shell Programming and Scripting
6
Shell Programming and Scripting
Filter output in curl
genius90
Hello guys, I'm writing a little script which sends me sms with my shell script via api of a sms provider. problem is I can't filter my curl output for this site: site url:...... Shell Programming and Scripting
1
Shell Programming and Scripting
Encapsulating output of CURL and/or WGET
SkySmart
i use curl and wget quite often. i set up alarms on their output. for instance, i would run a "wget" on a url and then search for certain strings within the output given by the "wget". the problem is, i cant get the entire output or response of my wget/curl command to show up correctly in...... Shell Programming and Scripting
3
Shell Programming and Scripting
ery weird wget/curl output - what should I do?
jstilby
Hi, I'm trying to write a script to download RedHat's errata digest. It comes in a txt.gz format, and i can get it easily with firefox. HOWEVER: output is VERY strange when donwloading it in a script. It seems I'm getting a file of the same size - but partially text and partly binary! It...... Shell Programming and Scripting
5
Shell Programming and Scripting
Getting cURL to output verbose to a file
caramandi
This is about to drive me crazy. What I want to do is simple: output ALL the verbose information from curl to a file I have read the manual, tried several options and searched this forum but no salvation... I'm using curl -k -Q "command" --user user:passwd --ftp-pasv --ftp-ssl -v...... Shell Programming and Scripting
1
Shell Programming and Scripting