bash-4.2$ echo mytext > with bash-4.2$ echo no > without bash-4.2$ mkdir -p foo/bar bash-4.2$ cp with* foo bash-4.2$ cp with* foo/bar bash-4.2$ tree . |-- foo | |-- bar | | |-- with | | `-- without | |-- with | `-- without |-- with `-- without bash-4.2$ grep -r mytext foo/bar/with:mytext foo/with:mytext with:mytext bash-4.2$ grep -r mytext . ./foo/bar/with:mytext ./foo/with:mytext ./with:mytext bash-4.2$ echo mytext | grep -r mytext foo/bar/with:mytext foo/with:mytext with:mytext bash-4.2$ echo no | grep -r mytext foo/bar/with:mytext foo/with:mytext with:mytext bash-4.2$ grep --version grep (GNU grep) 2.12 Copyright (C) 2012 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later . This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Written by Mike Haertel and others, see .