Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

bash grep

Name: Anonymous 2012-02-27 13:29

How do I grep a given path and not the contents of the file in bash? ls won't work because the path is actually an input file, $1. Thanks.

Name: Anonymous 2012-02-28 0:41

>>8
Some greps have the -q or --quiet option for this purpose. Besides, if you have to redirect stdout, you should redirect stderr, too.

OP should be careful with those regexes. Use ^ and $ to mark the beginning and end of the line, and use the dirname and basename commands to grab the parent directory and the filename, respectively (echo `basename $1` | grep -q lol).

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List