Terminal Speedtest Script MacOS I am looking for a Terminal Script for MacOS to monitor my bandwidth and ping etc. like this (linux) ->
https://gitgud.io/J0s3f/speedtest_cron/tree/master

I have the speedtest-cli installed via homebrew and I thought it must be possible to do a script that triggers a speed test every 10 minutes and repeats it for example 100 times. After it is finished, it puts the results in a .txt file.

I wanna do the same with a ping that executes e.g. 5 times every 10 Minutes and this for a couple of hours etc and get a results file too.

Background: I am having problems with my internet connection and the ISP call centre guy refusing to see a problem.
Background: I am having problems with my internet connection and the ISP call centre guy refusing to see a problem.

This is key to understanding your problem question.  What is the problem exactly that you’re are experiencing?  Going into detail here will help you (help us) come up with a solution that addresses your exact problem.
From your question, it seems that you are attempting to utilize (at least) two tools to determine what the issue is.  The problem is, neither tool is sufficient to get you accurate metrics to help you diagnose the perceived problem.
Ping
Ping measures how fast your network adapter responds to a request (a.k.a. Latency).   The problem with this is that you can have lightening fast latency (i.e. 10ms), but horrible bandwidth (56Kpbs) to transfer your files.
Where ping will come in handy is monitoring this latency over time assuming latency is the issue you're experiencing.
Bandwidth
You may have and pay for a high speed connection from your ISP, but what happens outside your ISP’s network could be the issue here.  See the post Improve file transfer performance over VPN for more details on this.  Basically, if the tech at your ISP is measuring data transfer rates from the ISP to your site it may be working fine (which is all the ISP is responsible for).
It’s entirely possible a server on a different network has a low bandwidth connection is creating the issues you are experiencing.