I have Debian8 (Jessie) running on my mcahine.
I run
$ ps aux | grep '[c]13dc8623fe6abc'
I get the following results
.bash_history:java -jar slave.jar -jnlpUrl http://tomcat-server:8080/slave-agent.jnlp -s c13dc8623fe6abc
.bash_history:java -jar slave.jar -jnlpUrl http://tomcat-server:8080/slave-agent.jnlp -s c13dc8623fe6abc
Script/build.sh:java -jar slave.jar -jnlpUrl http://tomcat-server:8080/slave-agent.jnlp -s c13dc8623fe6abc
The results returned are search results from bash script files on my system. This is not what I expect at all. I would expect it to grep/search the output of ps aux
.
Why is this strange behaviour happening in my system.?
As per the suggestion below, I have done the following
$ type ps
Output
::6+type ps
ps is /bin/ps
$ type grep
Output
::7+type grep
grep is aliased to `grep --color=auto -I -r --exclude=\*.{c.svn-base,o,.py,so*,a}'
After setting
$ PS4=':$BASH_SOURCE:$LINENO+'
$ set -x
After that If I do
$ ps aux | grep '[c]13dc8623fe6abc'
I get the following output.
::5+grep --color=auto -I -r '--exclude=*.c.svn-base' '--exclude=*.o' '--exclude=*..py' '--exclude=*.so*' '--exclude=*.a' '[c]13dc8623fe6abc'
::5+ps aux
.bash_history:java -jar slave.jar -jnlpUrl http://tomcat-server:8080/slave-agent.jnlp -s c13dc8623fe6abc
.bash_history:java -jar slave.jar -jnlpUrl http://tomcat-server:8080/slave-agent.jnlp -s c13dc8623fe6abc
Script/build.sh:java -jar slave.jar -jnlpUrl http://tomcat-server:8080/slave-agent.jnlp -s c13dc8623fe6abc
As we determined in comments, running this with set -x
enabled showed that an alias was adding a bunch of extra complexity to your grep
call.
To make this as robust as possible, let's both prevent the alias from executing (by using the command
buildin), and explicitly specify that your grep should be searching stdin (by passing -
as a filename, and using -e
to flag the hex string that follows as unambiguously representing the target to search for):
ps aux | command grep -e '[c]13dc8623fe6abc' -