Crazy_Bash Crazy_Bash - 6 months ago 55
Linux Question

wget: downloaded file name

I'm writing a script for bash and I need to get the name of the downloaded file using wget and put the name into $string

for example if I downloading this file below, I want to put it's name mxKL17DdgUhcr.jpg to $string

45439 (44K) [image/jpeg]
Saving to: «mxKL17DdgUhcr.jpg»

100%[===================================================================================================>] 45 439 --.-K/s в 0s

2011-12-20 12:25:33 (388 MB/s) - «mxKL17DdgUhcr.jpg» saved [45439/45439]


Use the basename command to extract the filename from the url. For example:

filename=$(basename "$url")
wget "$url"