H
H
hofix2020-08-19 19:08:16
linux
hofix, 2020-08-19 19:08:16

How to generate strings in Linux incrementing a numeric value?

How to generate strings in Linux by incrementing a numeric value to the desired number?

Input: site.com/images/1

Output txt with data:
site.com/images/1
site.com/images/2
site.com/images/3
site.com/images/4
......

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
AUser0, 2020-08-19
@hofix

The dumbest option:

for i in `seq 1 4`; do echo "site.com/images/${i}" >>out.txt; done

K
kocherman, 2020-08-19
@kocherman

echo site.com/images/{1..4} | xargs -n1 -P5 wget
where -P5 is the number of simultaneously downloading wget processes

echo site.com/images/{1..4} | xargs -n1 echo > ~/file.txt

save to ~/file.txt.
This code will help you understand how it works:
echo {{001..004},007,{009..011},077,770,1777}
echo {5..6}
echo {{001..004},007,{009..011},077,770,1777}{5..6}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question