[Solved] Having trouble with simple grep search

Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers [Solved] Having trouble with simple grep search
# 8  
Old 03-13-2014
Thank you, I got it now. I really appreciate that help!
# 9  
Old 03-13-2014
If you have something to match and something to exclude, you can achieve this in two connected commands:-
grep -E "a" file | grep -Evc "h"

The v flag is a negation, so the above will first find all records that match the condition (i.e. contain a) then count all records that do not match the second condition h

I hope that this helps,
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Trouble with tail and grep

Good Morning, i ran into some trouble this morning while 'improving' my monitoring stuff. i would like to get a warning when the number of mails sent (outbound) by postfix is above a certain number. so far, so easy. to test that i simply put cat /var/log/mail.info | grep 'to=<' | grep -v -e... (1 Reply)
Discussion started by: Mike
1 Replies

2. UNIX for Beginners Questions & Answers

Grep trouble in Bash

PH=(6H 0 0 JD 9S 0 KD 0) #input from .txt file In the above array, I am trying to get the computer to tell me at what indices the non-zeros are at. I don't understand why this doesn't work... grep -v -b "0" ph.txt > position.txt Isn't grep -v supposed to show non matches in Bash?... (2 Replies)
Discussion started by: cogiz
2 Replies

3. Shell Programming and Scripting

Trouble with simple cutting, joining

Made a file called assignment1.sh and this is what's inside - #!/bin/bash $ cut -c 2 sales.txt > regionalsales.txt $ cut -c 6 sales.txt > regionalsales.txt $ cut -c 1 territory.txt > terrsummary.txt $ cut -c 2 territory.txt > terrsummary.txt $ cut -c 3 territory.txt > terrsummary.txt $ sort... (1 Reply)
Discussion started by: htzdruk
1 Replies

4. Shell Programming and Scripting

Having a little trouble with grep

I am trying to make a script that has grep finding lines that I get from the cat command, that start with something and end with an argument. I can get the first part, but whenever I try to add on the part that looks at the end of the line too, it stops working. Any ideas why? Here is my script: ... (11 Replies)
Discussion started by: sammythesp3rmy
11 Replies

5. Linux

[SOLVED] Trouble adding Tun module

So I have Ubuntu running on a sheevaplug develop kit, but the damn kernel thing doesn't come with /dev/tun enabled. It was suggested that I look into using module assistant to compile & get this set up but I'm having issues. Linux ubuntu #2 PREEMPT Fri Aug 5 19:05:11 MDT 2011 armv5tel... (4 Replies)
Discussion started by: dpreviti
4 Replies

6. Shell Programming and Scripting

Emergency grep/delete trouble!!!

Hi everyone, thank you so much for reading. I built a user reference page from /etc/password for a class project. Now I need two shell scripts: 1) Add names to the reference page 2) Delete names from the reference page. I know grep -v is involved somehow and some piping but I am super stuck. ... (1 Reply)
Discussion started by: jsmpdx
1 Replies

7. UNIX for Dummies Questions & Answers

[Solved] Simple while loop does not exit

spath="/home/user/k/${1}" dpath="/home/user/seq/Nov17/${1}" cd $dpath ls -1 $spath > list c=1 while read list newlist=`echo $list | sed 's/.gz//' ` newnewlist=`echo $newlist | sed 's/.fastq//' ` do echo $c echo $list c=$(($c+1)) (6 Replies)
Discussion started by: analyst
6 Replies

8. Shell Programming and Scripting

[Solved] Strucked in Simple if

Whats the wrong with the following code: if ; then echo "File XYZ Exist" if ] ; then echo "File abc is not empty, script continues" else echo "File abc is empty, script aborts" exit 0 fi else echo "File XYZ does not exist" exit 0 Error: testscript.ksh:... (3 Replies)
Discussion started by: karumudi7
3 Replies

9. Shell Programming and Scripting

grep : having trouble with a single quote

Hi, I search for the string below which contains a single quote, some text '/home/myuser in the file myfile.txt as another user with the grep command as follows su - myuser -c "grep 'some text \'/home/myuser' myfile.txt" I also tried using two backslashes su - myuser... (6 Replies)
Discussion started by: cimcmahon
6 Replies

10. UNIX for Dummies Questions & Answers

Trouble with search and substitute

Hi there, I have a file with 1800+ lines and all are something like this: drwx--x--x 12960 4096 Oct 6 2006 palfvoet drwx--x--x 67205 4096 May 9 05:21 pallsopp drwx--x--x palmgren 4096 Oct 6 2006 palmgren now, as you... (3 Replies)
Discussion started by: besgal
3 Replies
Login or Register to Ask a Question