t30_9
t30_9

Reputation: 499

Pass parameter from list in file

i'm struggling with this topic: I've a file with a list of IDs, something like this:

34
23
478
12579
342356

On the other side, i've a command that i want to run, to show me the details for each object of the list (no much to say on this, is a specific command coming actually from a API). It looks like this, where "id" rappresents a single integer, which must exist in the previous list.

command-to-get-details str id

My idea was to loop in the first file with read, store the IDs in a variable through readarrayand pass them to the second command in a while loop. The problem with this solution is that i can't use readarray in this machine.

Is there any other solution to do this?

Thank you very much

Upvotes: 0

Views: 600

Answers (1)

Nic3500
Nic3500

Reputation: 8601

From https://mywiki.wooledge.org/BashFAQ/001

#!/bin/bash

while IFS= read -r id
do
    echo "command-o-get-details str $id"
done < "ids.txt"

Remove the echo to use your specific command.

Upvotes: 1

Related Questions