Yes, you can
/proc but you probably don't want to. In more detail:
Yes, you can run grep the binary contents of
/dev/sda1. But, with modern large hard disks, this will take a very long time and the result is not likely to be useful.
Yes, you can grep the contents of
/proc but be aware that your computer's memory is mapped in there as files. On a modern computer with gigabytes of RAM, this will take a long time to grep and, again, the result is not likely to be useful.
As an exception, if you are looking for data on a hard disk with a damaged file system, you might run
grep something /dev/sda1 as part of an attempt to recover the file's data.
Other problematic files in
The hard disks and hard disk partitions under
/dev can be, if one has enough patience, grepped. Other files (hat tip: user2313067), however, may cause problems:
/dev/zero is a file of infinite length. Fortunately,
grep (at least the GNU version) is smart enough to skip it:
$ grep something /dev/zero
grep: input is too large to count
/dev/urandom are also infinite. The command
grep something /dev/random will run forever unless
grep is signaled to stop.
It can be useful to grep
/dev/urandom when generating passwords. To get, for example, five random alphanumeric characters:
$ grep --text -o '[[:alnum:]]' /dev/urandom | head -c 10
This is not infinite because, after it has received enough characters,
head closes the pipe causing grep to terminate.
"...links ... create infinite loops when traversed..."
Grep (at least the GNU version) is smart enough not to do that. Let's consider two cases:
-r option, grep does not follow symbolic links unless they are explicitly specified on the command line. Hence, infinite loops are not possible.
-R option, grep does follow symbolic links but it checks them and refuses to get caught in a loop. To illustrate:
$ mkdir a
$ ln -s ../ a/b
$ grep -R something .
grep: warning: ./a/b: recursive directory loop
Excluding problematic directories from
As an aside,
grep provides a limited facility to stop grep from searching certain files or directories. For example, you can exclude all directories named
dev from grep's recursive search with:
grep --exclude-dir proc --exclude-dir sys --exclude-dir dev -r something /
Alternatively, we can exclude
dev using bash's extended globs:
shopt -s extglob
grep -r something /!(proc|sys|dev)