Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to Use the Linux watch Command with Pipeline Commands
#1

    How to Use the Linux watch Command with Pipeline Commands
   

How to Use the Linux watch Command with Pipeline Commands


   

The watch command can also be helpful with other pipeline commands:


   

Monitoring Files


   

To view a particular file's status or its changes, use the following command:

   
watch -d 'ls -l | fgrep newuser'
   

Here, "newuser" is the username, and "ls -l" represents the files in the user directory.


   

Using watch Command as a Clock


   

You can use the watch command as a clock by executing the specified command below:

   
watch –t date
   

The executed "date" command will display the clock and date only.


   

Viewing Network Status


   

It's possible to use the watch command to monitor your network. For example:

   
watch "netstat -anp | grep -c ':22\b.*LISTEN'"
   

The command will display active connections on port 22.


   

   
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)