Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

grep command 1

Status
Not open for further replies.

ahmedmt1981

Technical User
Nov 22, 2006
20
AE
Dear
as we know grep commands used as follows

> grep "text" filename

filename: "the line related to the text"

what is the option comes with grep command diplaying line without diplaying file name
I'm making a script and the filename that comes with the line cousing me some problems

Thank you all soooo much
 
In the absence of an option (which there probably is in some flavours) try:

grep "text" filename | cut -d':' -f2

 
In Tru64 and Solaris 8 it is grep -h 'text' filename, but the best way to check is to use the man pages. Please see man grep.

I hope that helps.

Mike
 
Hi ahmedmt1981,

For something like an option or parameter for a command you already know, you should always check the man page first...
Code:
$ [b]man grep[/b]

User Commands                                             grep(1)

NAME
     grep - search a file for a pattern

SYNOPSIS
     /usr/bin/grep    [-bchilnsvw]     limited-regular-expression
     [filename...]

     /usr/xpg4/bin/grep [-E | -F]  [-c | -l  |  -q]   [-bhinsvwx]
     -e pattern_list...  [-f pattern_file]... [file...]

     /usr/xpg4/bin/grep [-E | -F]  [-c | -l  |  -q]   [-bhinsvwx]
     [-e pattern_list...] -f pattern_file... [file...]

     /usr/xpg4/bin/grep [-E | -F]  [-c | -l  |  -q]   [-bhinsvwx]
     pattern [file...]

     The grep utility searches  text  files  for  a  pattern  and
     prints  all lines that contain that pattern.  It uses a com-
     pact non-deterministic algorithm.

     Be careful using the characters $, *, [, ^, |, (, ),  and  \
     in  the pattern_list because they are also meaningful to the...

<...edited...>

     -h       Prevents the name of the file containing the match-
              ing  line  from  being appended to that line.  Used
              when searching multiple files.

<...edited...>
The man page will always give you the parameters and options for the command on that machine. It will also sometimes give you examples of use and a list of other related commands to look into. The man page would have given you the option you were looking for in the time it would take to read it (minutes), instead of the day or two it will take to get a response on the web.

Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top