New answers tagged


In addition: You can also try specifying the width; this will make full use of your screen width. In my case, the following gives a perfectly formed output. Do customize the width parameter as per you monitor/terminal size: watch -d "ps -ef --width 1000 | grep java | grep -v grep "


You can use ANSI escape sequences. To set a color and style desired, there is a syntax \033[#m where # can be a valid set of semicolon separated numbers. You can define colors such as CLEAR="\033[0m" GREEN="\033[0;32m" BLUE="\033[0;34m" PURPLE="\033[0;35m" RED="\033[0;31m" YELLOW="\033[1;33m" And use them such as echo -e "${GREEN}Updated${CLEAR}" Check ...


There are two main categories of watch commands (of the ones that are to run commands periodically, watch is not a standard command, there are even systems where watch does something completely different like snooping on another tty line on FreeBSD). One that already passes the concatenation of its arguments with spaces to a shell (it does in effect call sh ...


The difference may be seen via strace: $ strace -ff -o bq watch sh -c 'ls\ /tmp/|wc -l' ^C $ strace -ff -o nobq watch sh -c 'ls /tmp/|wc -l' ^C $ grep exec bq* | grep sh bq.29218:execve("/usr/bin/watch", ["watch", "sh", "-c", "ls\\ /tmp/|wc -l"], [/* 54 vars */]) = 0 bq.29219:execve("/bin/sh", ["sh", "-c", "sh -c ls\\ /tmp/|wc -l"], [/* 56 vars */]) = 0 ...

Top 50 recent answers are included