def arg = "crx3" //Execute top with command path display (c) //chnage col size so that complete display is seen (export COLUMNS) //exclude current command (grep -v) println pipeEx("export COLUMNS=1000;top -cbn 1 | grep java | grep '$arg' | grep -v COLUMNS") println pipeEx("export COLUMNS=1000;top -cbn 1 -H| grep java | grep '$arg'| grep -v COLUMNS") def pipeEx(def cmd) { ['sh', '-c', cmd].execute().text }