how to use wget with Many URL's in .txt file to download and save as
You can use this awk|xargs one-liner:
awk '{url=$1; $1="";{sub(/ /,"");out=url" -O \""$0"\""}; print out}' file.txt | xargs -L 1 wget
Explanation:
url=$1 # temp var inside awk
$1="" # replace url with null space
{sub(/ /,"");out=url" -O \""$0"\""} # need to output var
sub(/ /,"") # need to trim leading white space
out=url" -O \""$0"\"" # line formatting with escaping characters
print out # シ
xargs -L 1 wget # get awk output line by line to wget
plus some awk sintax sugar
Example:
cat << EOF >> file.txt
https://www.openssl.org/source/old/1.1.1/openssl-1.1.1k.tar.gz name_of_the_file2
https://www.openssl.org/source/old/1.1.1/openssl-1.1.1j.tar.gz name of_the_file3
https://www.openssl.org/source/old/1.1.1/openssl-1.1.1i.tar.gz name of the_file4
https://www.openssl.org/source/old/1.1.1/openssl-1.1.1h.tar.gz name of the file5
EOF
awk '{url=$1; $1="";{sub(/ /,"");out=url" -O \""$0"\""}; print out}' file.txt | xargs -L 1 wget
ls -1
name_of_the_file2
'name of_the_file3'
'name of the_file4'
'name of the file5'