How do I grep this command that includes a wildcard?
How do I grep stderr?
The grep does not seem to do anything:
$ less /Users/raine/.nvm/versions/node/v5.5.0/lib/node_modules/* | grep "Not a file"
/Users/raine/.nvm/versions/node/v5.5.0/lib/node_modules/truffle is a directory
/Users/raine/.nvm/versions/node/v5.5.0/lib/node_modules/wunderline is a directory
/Users/raine/.nvm/versions/node/v5.5.0/lib/node_modules/yo is a directory
This is a very hacky use of less, and probably worthy of another question, but my intention is to find broken symlinks in this directory. It happens to be that less will print is a directory
if it is valid and Not a file or directory
if it is invalid. I believe it is worth asking anyway as this is indicative of my lack of understanding of wildcard operators stderr.
less ... 2>&1 | grep yo
– Satō Katsura Jun 29 '16 at 17:04grep
the error messages fromless
, andless
prints error messages tostderr
. – Satō Katsura Jun 29 '16 at 17:11cat
might be easier...cat * > /dev/null
will send the results to stderr. If you want to catch it in a variable,badlines=$(cat * 2>&1 >/dev/null) ; echo "$badlines"
– Stephen Harris Jun 29 '16 at 17:14