Here is the description of grep
from GNU.org:
grep
searches input files for lines containing a match to a given pattern list. When it finds a match in a line, it copies the line to standard output (by default), or produces whatever other sort of output you have requested with options.
I have this command that I use often, which gives the name of the currently connected monitor:
xrandr | grep " connected " | awk '{ print$1 }'
I can't see any files in this command, or links to them, so what exactly is going on? Is grep
used for other stuff apart from searching files?
grep
and just haveawk
do the search itself with the following command:xrandr | awk '/ connected / { print $1 }'