Help with Handling multiple argument in shell script

Hi i have written a shell script that takes only single ip address from the user and calculates its latency and reliability, can you please tell me that what should be done if i want that user should enter 100 or 1000 ip address

You should probably repeat what you're doing within a loop. But no one will be able to provide you with more specific advice since you neglected to share your code.

Regards,
Alister

1 Like

"User should enter 100 or 1000 IP addresses" - by this statement, do you mean user provides 100's of IP addresses in the form of a file? If so, then wrap the logic you have for one IP address into a while block and repeat the same for each IP address read from the file.

1 Like

Hi my code is

#!/bin/bash

workOnIP () {
    echo "The IP Address you've entred is: $1"
    varip="$1"
    
    ### Code to process IP address
    
}

while read IP
do
    workOnIP $IP
done < file_containing_100_IPs
1 Like

Thanks a lot :slight_smile: