A
A
Anthony Barkovsky2020-01-18 03:29:38
linux
Anthony Barkovsky, 2020-01-18 03:29:38

How in bash wget to save a file with the name from the link part?

Good day.
There is a file with 10000+ links that needs to be downloaded using wget.
In the link file in the form:
google.com/page?=abcde
The html pages will be saved.
Accordingly, if you register,
wget -i links.txt
then the files will be in the form

  • index.html
  • index.html.1
  • index.html.2

Is it possible to use wget to save each file with the name of the link part as abcde.html (cats.com/page?= abcde ) or at least randomize the name.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
pfg21, 2020-01-18
@velvetflower

Yes, it is quite. using the wget
-o, --output-file=FILE option write messages to FILE by the
script, you read the file and give wget the url from the file and the file name that the script generates from the url.

S
sergey, 2020-01-18
kuzmin @sergueik

velvetflower can be
https://stackoverflow.com/questions/1521462/loopin...

a A
b B
c C

a A
b B
c C

and I forgot to say if a column in a file with a list *should* remain alone for some reason, then get the name from the url using sed like something like:
a
b
c

while read s ; do
d=$(echo $s|sed's|^.*/||')
   echo "$s" "$d" ; 
done </tmp/a.txt

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question