* using grep with both -l and -n
@ 2004-02-20 0:00 Jeffrey Holle
2004-02-20 3:04 ` Mike Castle
0 siblings, 1 reply; 2+ messages in thread
From: Jeffrey Holle @ 2004-02-20 0:00 UTC (permalink / raw)
To: linux-console
I've actually got two questions about grep.
First, can the -l, which just prints the matching filenames, and -n,
which includes the matched line number using the syntax
"filename:lineno", be combined to affect.
What I find is that adding -n makes inclusion of -l a noop.
The reason I ask is I'm using grep to generate .gdbinit files. the
syntax that -n emits is right on, except for the extra stuff that is
normally suppressed by -l.
The second question is there a way to defeat the default behavior of not
including the filename when -n is used and only one file is included in
the search? In this case, it prints just the lineno.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: using grep with both -l and -n
2004-02-20 0:00 using grep with both -l and -n Jeffrey Holle
@ 2004-02-20 3:04 ` Mike Castle
0 siblings, 0 replies; 2+ messages in thread
From: Mike Castle @ 2004-02-20 3:04 UTC (permalink / raw)
To: Jeffrey Holle; +Cc: linux-console
On Thu, Feb 19, 2004 at 04:00:07PM -0800, Jeffrey Holle wrote:
> The reason I ask is I'm using grep to generate .gdbinit files. the
> syntax that -n emits is right on, except for the extra stuff that is
> normally suppressed by -l.
Would this work for you:
awk '{print $1}'
> The second question is there a way to defeat the default behavior of not
> including the filename when -n is used and only one file is included in
> the search? In this case, it prints just the lineno.
Add /dev/null to the list of files.
mrc
--
Mike Castle dalgoda@ix.netcom.com www.netcom.com/~dalgoda/
We are all of us living in the shadow of Manhattan. -- Watchmen
fatal ("You are in a maze of twisty compiler features, all different"); -- gcc
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-02-20 3:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-02-20 0:00 using grep with both -l and -n Jeffrey Holle
2004-02-20 3:04 ` Mike Castle
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).