grep … matches..and that not matches..-l.. -L

$grep -r -l tcp_max *
sysctl_net_ipv4.c
tcp.c
tcp_cong.c
tcp_input.c
tcp_output.c
$
$grep -r -L tcp_max *
af_inet.c
ah4.c
arp.c
cipso_ipv4.c
datagram.c
devinet.c
esp4.c
fib_frontend.c
fib_hash.c
fib_lookup.h
fib_rules.c
fib_semantics.c
fib_trie.c
icmp.c
igmp.c
inet_connection_sock.c
inet_diag.c
inet_fragment.c
inet_hashtables.c
inet_lro.c
inetpeer.c
inet_timewait_sock.c
ipcomp.c
ipconfig.c
ip_forward.c
ip_fragment.c
ip_gre.c
ip_input.c
ipip.c
ipmr.c
ip_options.c
ip_output.c
ip_sockglue.c
Kconfig
Makefile
netfilter/ipt_ECN.c
netfilter/nf_nat_amanda.c
netfilter/nf_conntrack_l3proto_ipv4.c
netfilter/nf_nat_proto_dccp.c
netfilter/iptable_security.c
netfilter/ipt_ULOG.c
netfilter/ipt_ecn.c
netfilter/ip_tables.c
netfilter/ip_queue.c
netfilter/iptable_filter.c
netfilter/ipt_REJECT.c
netfilter/nf_nat_proto_tcp.c
netfilter/nf_nat_proto_unknown.c
netfilter/nf_defrag_ipv4.c
netfilter/ipt_CLUSTERIP.c
netfilter/nf_nat_ftp.c
netfilter/nf_nat_rule.c
netfilter/nf_nat_sip.c
netfilter/ipt_MASQUERADE.c
netfilter/Kconfig
netfilter/arpt_mangle.c
netfilter/nf_nat_proto_icmp.c
netfilter/nf_nat_snmp_basic.c
netfilter/nf_conntrack_proto_icmp.c
netfilter/nf_nat_standalone.c
netfilter/nf_nat_proto_sctp.c
netfilter/nf_conntrack_l3proto_ipv4_compat.c
netfilter/nf_nat_tftp.c
netfilter/ipt_LOG.c
netfilter/nf_nat_irc.c
netfilter/Makefile
netfilter/nf_nat_h323.c
netfilter/nf_nat_helper.c
netfilter/nf_nat_proto_udp.c
netfilter/ipt_REDIRECT.c
netfilter/arptable_filter.c
netfilter/nf_nat_core.c
netfilter/iptable_mangle.c
netfilter/nf_nat_proto_gre.c
netfilter/ipt_NETMAP.c
netfilter/nf_nat_proto_udplite.c
netfilter/iptable_raw.c
netfilter/ipt_addrtype.c
netfilter/nf_nat_pptp.c
netfilter/nf_nat_proto_common.c
netfilter/ipt_ah.c
netfilter/arp_tables.c
netfilter.c
proc.c
protocol.c
raw.c
route.c
syncookies.c
tcp_bic.c
tcp_cubic.c
tcp_diag.c
tcp_highspeed.c
tcp_htcp.c
tcp_hybla.c
tcp_illinois.c
tcp_ipv4.c
tcp_lp.c
tcp_minisocks.c
tcp_probe.c
tcp_scalable.c
tcp_timer.c
tcp_vegas.c
tcp_vegas.h
tcp_veno.c
tcp_westwood.c
tcp_yeah.c
tunnel4.c
udp.c
udp_impl.h
udplite.c
xfrm4_input.c
xfrm4_mode_beet.c
xfrm4_mode_transport.c
xfrm4_mode_tunnel.c
xfrm4_output.c
xfrm4_policy.c
xfrm4_state.c
xfrm4_tunnel.c
$

“-L”

Suppress normal output; instead print the name of each input file from which no output would normally have been printed.
The scanning will stop on the first match.

“-l”

Suppress normal output; instead print the name of each input file from which output would normally have been printed.
The scanning will stop on the first match. (-l is specified by POSIX.)

source : debian manual for grep.


src/cmd/grep/main.c

     1: #define EXTERN
     2: #include        "grep.h"
     3:

     7: {
      8:         fprint(2, "usage: grep [-%s] [-f file] [-e expr] [file ...]n", validflags);
      9:         exits("usage");

hg.pdos.csail.mit.edu/hg/plan9 - Lucent - C -


| Paper |

The key to problem-solving on the UNIX system
is to identify the right primitive operations and to
put them at the right place. UNIX programs tend
to solve general problems rather than special cas
es. In a very loose sense, the programs are orth
ogonal,spanning the space of jobs to be done (al
though with a fairamount of overlap for reasons
of history, convenience or efficiency). Functions a
re placed where they will do the most good: there
shouldn’t be a pager in every program that produ
ces output any more thanthere should be filename
pattern matching in every program that uses filenames.

One thing that UNIX does not need
is more features. It is successful in part because it has a
small number of good ideas that work well together.
Merely adding features does not make it easier for users
to do things — it just makes the manual thicker. The right
solution in the right place is always more effective than
haphazard hacking.

source :
Program design in the UNIX† environment
Rob Pike
Brian W. Kernighan