B
B
brar2020-06-24 21:54:27
bash
brar, 2020-06-24 21:54:27

How to substitute a variable taken from the list in the file into the URL?

There is a line-by-line list of users in a text file.
user1
user2
..
userN

There is an API that, when requested, curl http://address.ru/api/user1/returns various information about the user (in this case, user1 in this case) in json format.
How to make a script that will take the username line by line from the users.txt file, substitute it in curl and write the response line by line to another out.txt file?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
X
xotkot, 2020-06-25
@brar

Yes, everything seems to be simple to the point of banality, isn't it?

for user in $(cat in.txt); do
  curl -s "http://address.ru/api/$user/" >> out.txt
done

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question