/usr/bin/time Shell Scripting Function

Hello, I have made a Linux Shell Script that downloads 6 files from the Internet and then deletes them. Now i want to use the function "/usr/bin/time" and "bc" to calculate how long the avergate run time for the shell script is. I therefore need to do it 100 times. My shell script code is below:

#!/bin/bash/
for I in {1..6}
do
        echo "Downloading file number $I "
        wget --user=os --password=yda http://osyda50.hive.no/0$I.html

        echo "Deleting file number $I "
        rm 0$I.html
done
#!/bin/bash/

That won't work. Try:

#!/bin/bash

There's no /usr/bin/time on my or most systems. 'time' is generally a shell builtin.

It also doesn't output data in a format very amenable to processing.

Since you have BASH you have the seconds variable.

START="$SECONDS"

for ((N=0; N<100; N++))
do
        for I in {1..6}
        do
                echo "Downloading file number $I "
                wget --user=os --password=yda http://osyda50.hive.no/0$I.html

                echo "Deleting file number $I "
                rm 0$I.html
        done
done

AVGDURATION="$(( (SECONDS-START)/100 ));

echo "Avg duration is $AVGDURATION"

Also: wget can download more than one file at once, and rm can delete more than one file at once. If you use wget on several files at once it's much faster, since you don't need to disconnect and reconnect for each individual file. You can get rid of your original for-loop completely:

wget --user=os --password=yda http://osyda50.hive.no/0{1..6}.html
rm 0{1..6}.html

Thank you for your reply Mr Corona688.

My task was:

:/$ which time
/usr/bin/time

We have a homework forum and homework rules, which you're not in and not following, respectively. Please do so.

Oh, well, can you help me with the code? It is my third script in Linux. I really need to learn this.

This is my bash script:

#!/bin/bash

/usr/bin/time
for I in {1.100}
do
        sh 1b.sh | bc
done

We have a homework forum and homework rules, which you're not in and not following, respectively. Please post in the homework forum, and please obey its rules. We can't help you until you do.

Ok, thank you for the good advice.