'saving output of nettop to file ( mac ) [closed]

I'm trying to save the output of nettop from my terminal to a text file ( maybe .csv ) what I want to do is be able to isolate the different values, specifically I want to track the bytes coming in from a particular application ( so that i can reference that file in another application ) I'm not very familiar with bash scripting but I imagine the right script could accomplish this sort of thing, or is there a better way?



Solution 1:[1]

You want the -L option. nettop -L 1, for example, will output a single sample in .csv format which will give you what you're looking for.

Solution 2:[2]

You can redirect the output of any terminal program to a file using the > character. in the terminal try: nettop > output.txt

that will save the output of nettop to the file output.txt. If you want to view the output from nettop and save it at the same time, try this: nettop | tee output.txt

that will "pipe" the output to the program "tee" which will print it to the terminal and write it to the file.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Glyph
Solution 2 Isaac Hanson