duminică, 2 septembrie 2012

Tips and tricks: watch and cat

Sometimes it is necessary to find solutions.

Today's example involves two linux commands:

watch and cat

Here is a simple method by creating a script that returns an output:

while [ 1 ]; do cat /proc/meminfo; date; echo; sleep 1; done

Make this script executable and name it: meminfo

Output is then processed by the command:

$ watch -d ./meminfo 

This simple method can be applied to other files ...

2 comentarii:

Rob Woolley spunea...

Watch is awesome.

You don't need the while loop. It is redundant when using watch. The date statement is also redundant because it prints it in the top right corner.

watch -d -n1 "cat /proc/meminfo"

Catalin George Festila spunea...

It's not just one meminfo command. It's one script with commands. I don't think is redundant more than ...1 sec (see sleep), but you can use that to make some logs .

Trimiteți un comentariu