Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
189 views
in Technique[技术] by (71.8m points)

linux - Curl : problem when I try to redirect output to file

I use this curl command to download a setup.exe :

curl -k -u login:Password -O "https://url/to/my/setup.exe"

I want to get the time total :

curl -s -w 'total : %{time_total}
' -k -u login:Password -O "https://url/to/my/setup.exe"
total : 41.165108

I want to redirect the output ( total : 41.165108 ) in an external file. I try :

curl -o test.txt -s -w 'total : %{time_total}
' -k -u login:Password -O "https://url/to/my/setup.exe"
curl -s -w 'total : %{time_total}
' -k -u login:Password -O "https://url/to/my/setup.exe" > test.txt

But it doesn't work...

Someone to show me ?

Thanks !


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Just combine the two things you've tried:

curl -s -w 'total : %{time_total}
' -k -u login:Password 
    -O "https://url/to/my/setup.exe" -o setup.exe > total.txt
#                                    ~~~~~~~~~~~~ ~~~~~~~~~~~
  • setup.exe will contain the downloaded file
  • total.txt will contain the total

The -o doesn't influence where the output of -w goes.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...