1
Specifically, I am trying to run the following command on both CentOS and Fedora14 (same issue with both)
watch sudo jmap -heap 31945
However, there are a few lines of standard error that screw up the output after jmap is called more than once:
Attaching to process ID 31945, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 14.2-b01
These lines are stripped if I run:
sudo jmap -heap 31945 2> /dev/null
However, if I try:
watch sudo jmap -heap 31945 2> /dev/null
then too many lines are removed (many lines of the actual output are removed).
Why is this happening? Is there a way to fix this?
Any suggestions for cases in which the command I want to pass to watch has quotes in it? – jonderry – 2011-04-28T20:24:27.573
@jonderry Two options: Use different quotes (e.g.
watch 'something "do something"'
), or escape the quotes (watch 'something \'do something\''
). – Kromey – 2011-04-28T20:25:38.827Neither of these works for me. For example, if I run
ps -ef | awk -F' ' '{print $2}'
, I get the pids for all processes. However,watch "ps -ef | awk -F' ' '{print $2}'"
gives incorrect field extraction, andwatch "ps -ef | awk -F\' \' \'{print $2}\'"
leads to an unterminated command. – jonderry – 2011-04-28T20:39:15.630@jonderry Looks as if I may have lead you astray with the escaping of the single quotes. The first form you tried, however, does work -- after you escape the $ in $2, that is:
– Kromey – 2011-04-28T21:49:29.067watch "ps -ef | awk -F' ' '{print \$2}'"
. See also this page on quoting and escaping in Bash: http://wiki.bash-hackers.org/syntax/quoting