Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Grep command to show the number of results Post 303042551 by abdossamad2003 on Sunday 29th of December 2019 09:06:17 AM
Old 12-29-2019
Grep command to show the number of results

Hi
I wanted to know if there is an option in grep command to show the number of results (not the number of lines of findings).


Thanks
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

diffrent results between command line and scripted grep

When I type a command at the command line it supplies one result and the exact same command in a script egrep '^01|^02|^03|^04' file > fileout count = 29353 same count in the script yields a count of 23492 is there any reason this could be happening. (1 Reply)
Discussion started by: r1500
1 Replies

2. UNIX for Dummies Questions & Answers

My ps -ef|grep command results are chopped off

On our one HP-UX 11i box, we have some very long paths defined. When I want to check on our user processes running, the resulting paths are chopped off. /xyz/abc/123/......./server/b is really a process running in the ..../server/bin directory. Is this a terminal problem or buffer length... (1 Reply)
Discussion started by: bsp18974
1 Replies

3. UNIX for Dummies Questions & Answers

ps results - to show user's ps only

hi! how do i make ps results to only shows what's owned by users current job/background process only currently when users issuing ps: I just wanted the result when the user is issuing ps aux is same as when they're doing ps x like this: (which shows result on user's current background... (13 Replies)
Discussion started by: rdns
13 Replies

4. UNIX for Dummies Questions & Answers

putting grep -c results number in a variable

I want to display "no results found" if a grep search of a name that the user inputs is not found anywhere in a certain file, Right now I have this, but doesn't seem to work. Im not sure what to change. read name results=grep -c $name file if ; then echo "No results found." exit... (1 Reply)
Discussion started by: busdude
1 Replies

5. Shell Programming and Scripting

Show date/time with tail|grep command

Hi, I have a log file without date/time, and I want that everytime tail|grep find something it displays the date/time and the line. I have tried something like this command but without any luck to display the date/time: tail -F catalina.out | sed "s/^/`date `/" | egrep ... (6 Replies)
Discussion started by: julugu
6 Replies

6. UNIX for Dummies Questions & Answers

Pipe results of Grep Command to LS Comand

I'm using the command grep -l XYZ to get a list of files containing the string XYZ. Then I using the comand ls -l ABC to get the create date timestamp of the each file. I've tried combining the comands using the pipe command, grep -l XYZ | ls -l, but its not working. What am I doing wrong? (3 Replies)
Discussion started by: jhtate
3 Replies

7. Shell Programming and Scripting

Grep command to show only process name

Can I modify the grep command to show only a process name? Currently I run ps -efa | grep chk_web to get the following: mousr 3395 1 0 09:36:06 pts/10 0:00 sh /var/opt/scripts/chk_web.sh Can this be changed in any way to get only: /var/opt/scripts/chk_web.sh or chk_web.sh. I... (3 Replies)
Discussion started by: runnerpaul
3 Replies

8. UNIX for Dummies Questions & Answers

Acting on results from a grep command

Hi, I am currently reading a tar file and searching for a particular word using grep e.g. Plane. At the moment, if a sentence is found with the word "Plane" the sentence itself is piped to another file. Here is the code i am using; for jar in 'cat jar_file.tar'; do tar -tvf... (3 Replies)
Discussion started by: crunchie
3 Replies

9. Shell Programming and Scripting

How to use command tail -f & show line number.

Hello Guys, I have created function which is as follow: tail -f filename |grep "Key word" output from this command 19-11-2011 21:09:15,234 - INFO Numbement - error number:result = :11 19-11-2011 21:09:15,286 - INFO Numbement - error number:result = :11 19-11-2011 21:09:15,523 - INFO... (5 Replies)
Discussion started by: ooilinlove
5 Replies

10. Shell Programming and Scripting

Cannot get results from grep command

Hi, i have a file hello.log which as several line that look like the below 2015-12-07 09:46:56 0:339 120.111.12.12 POST /helloWorld 2015-12-07 09:46:57 0:439 122.111.12.12 POST /helloWorld .... when i grep expecting to see results like the below. ... (6 Replies)
Discussion started by: mohtashims
6 Replies
GIT-GREP(1)							    Git Manual							       GIT-GREP(1)

NAME
git-grep - Print lines matching a pattern SYNOPSIS
git grep [-a | --text] [-I] [-i | --ignore-case] [-w | --word-regexp] [-v | --invert-match] [-h|-H] [--full-name] [-E | --extended-regexp] [-G | --basic-regexp] [-F | --fixed-strings] [-n] [-l | --files-with-matches] [-L | --files-without-match] [-z | --null] [-c | --count] [--all-match] [-q | --quiet] [--max-depth <depth>] [--color[=<when>] | --no-color] [-A <post-context>] [-B <pre-context>] [-C <context>] [-f <file>] [-e] <pattern> [--and|--or|--not|(|)|-e <pattern>...] [--cached | --no-index | <tree>...] [--] [<pathspec>...] DESCRIPTION
Look for specified patterns in the tracked files in the work tree, blobs registered in the index file, or blobs in given tree objects. OPTIONS
--cached Instead of searching tracked files in the working tree, search blobs registered in the index file. --no-index Search files in the current directory, not just those tracked by git. -a, --text Process binary files as if they were text. -i, --ignore-case Ignore case differences between the patterns and the files. -I Don't match the pattern in binary files. --max-depth <depth> For each <pathspec> given on command line, descend at most <depth> levels of directories. A negative value means no limit. -w, --word-regexp Match the pattern only at word boundary (either begin at the beginning of a line, or preceded by a non-word character; end at the end of a line or followed by a non-word character). -v, --invert-match Select non-matching lines. -h, -H By default, the command shows the filename for each match. -h option is used to suppress this output. -H is there for completeness and does not do anything except it overrides -h given earlier on the command line. --full-name When run from a subdirectory, the command usually outputs paths relative to the current directory. This option forces paths to be output relative to the project top directory. -E, --extended-regexp, -G, --basic-regexp Use POSIX extended/basic regexp for patterns. Default is to use basic regexp. -F, --fixed-strings Use fixed strings for patterns (don't interpret pattern as a regex). -n Prefix the line number to matching lines. -l, --files-with-matches, --name-only, -L, --files-without-match Instead of showing every matched line, show only the names of files that contain (or do not contain) matches. For better compatibility with git diff, --name-only is a synonym for --files-with-matches. -z, --null Output instead of the character that normally follows a file name. -c, --count Instead of showing every matched line, show the number of lines that match. --color[=<when>] Show colored matches. The value must be always (the default), never, or auto. --no-color Turn off match highlighting, even when the configuration file gives the default to color output. Same as --color=never. -[ABC] <context> Show context trailing (A -- after), or leading (B -- before), or both (C -- context) lines, and place a line containing -- between contiguous groups of matches. -<num> A shortcut for specifying -C<num>. -p, --show-function Show the preceding line that contains the function name of the match, unless the matching line is a function name itself. The name is determined in the same way as git diff works out patch hunk headers (see Defining a custom hunk-header in gitattributes(5)). -f <file> Read patterns from <file>, one per line. -e The next parameter is the pattern. This option has to be used for patterns starting with - and should be used in scripts passing user input to grep. Multiple patterns are combined by or. --and, --or, --not, ( ... ) Specify how multiple patterns are combined using Boolean expressions. --or is the default operator. --and has higher precedence than --or. -e has to be used for all patterns. --all-match When giving multiple pattern expressions combined with --or, this flag is specified to limit the match to files that have lines to match all of them. -q, --quiet Do not output matched lines; instead, exit with status 0 when there is a match and with non-zero status when there isn't. <tree>... Instead of searching tracked files in the working tree, search blobs in the given trees. -- Signals the end of options; the rest of the parameters are <pathspec> limiters. <pathspec>... If given, limit the search to paths matching at least one pattern. Both leading paths match and glob(7) patterns are supported. EXAMPLES
git grep time_t -- *.[ch] Looks for time_t in all tracked .c and .h files in the working directory and its subdirectories. git grep -e '#define' --and ( -e MAX_PATH -e PATH_MAX ) Looks for a line that has #define and either MAX_PATH or PATH_MAX. git grep --all-match -e NODE -e Unexpected Looks for a line that has NODE or Unexpected in files that have lines that match both. AUTHOR
Originally written by Linus Torvalds <torvalds@osdl.org[1]>, later revamped by Junio C Hamano. DOCUMENTATION
Documentation by Junio C Hamano and the git-list <git@vger.kernel.org[2]>. GIT
Part of the git(1) suite NOTES
1. torvalds@osdl.org mailto:torvalds@osdl.org 2. git@vger.kernel.org mailto:git@vger.kernel.org Git 1.7.1 07/05/2010 GIT-GREP(1)
All times are GMT -4. The time now is 07:08 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy