Category: Bash

  • Watch without watch

    Heres a little bash script to do what watch does without having to install watch

    Start by creating watch.sh

    #!/bin/bash
    
    while true; do
        clear
        $2
        sleep $1  # adjust interval as needed
    done

    make sure to set the permissions to be able to execute

    chmod a+x watch.sh

    execute with

    ./watch.sh 2 "du -h -d 1"

    where the first parameter is interval in seconds and the second is the command wrapped in double quotes