finding exact characters

Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers finding exact characters
# 1  
Old 03-23-2002
Question finding exact characters

I want to grep from a file an exact character match.
I tried grep -c "$a $b" $file
where a=6 and b=2
the problem is that I get: 6 2 and 6 20
I just need a count of the occurrence.
I'm using the Bourne shell.
I've also tried grep -c '$a $b' $file;
not sure how to do this - any suggestions?
# 2  
Old 03-25-2002
If you are using GNU grep, you can use the word boundary pattern matches:

grep -c "\<6 2\>" file
# 3  
Old 03-25-2002
Thanks, I'm using sco unix; I did try grep -c "$a $b$" filename. That seemed to work.
# 4  
Old 03-25-2002
Computer Re: finding exact characters

grep -c -x "$a $b" $file
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grep exact match without period or other special characters

If I have a file like the following abc.1 abc abc_1 abc..1 abc*1 abc@1 abc def ghr def...... ddef 5466 def ed def** 123445 I`m trying to find exact words from the list abc def (4 Replies)
Discussion started by: ritakadm
4 Replies

2. Shell Programming and Scripting

Finding first 6 characters

Hi , I'm using KSH88 I tried the following example to get the last 6 characters from a string echo 'abcdefghids' | sed 's/.*\(.\{6\}\)$/\1/' What chages i need to do to get the first 6 characters from the string my desired output should be abcdef Thank you (6 Replies)
Discussion started by: smile689
6 Replies

3. UNIX for Dummies Questions & Answers

[Solved] Listing files starting with p or f and with the exact length of 3 characters

Hello, I need some help. How can I list files starting with p or f and with the exact length of 3 characters? (2 Replies)
Discussion started by: airbebe
2 Replies

4. Shell Programming and Scripting

finding number in exact column

Dear all, I want to find a number in exact column but I don't know how to do it. Here is the thing, data is shown below, and I want to find 416 in the first column and print it out, how should I deal with it? Thank you very much! ab33 50S01S 958 279.068999 67.251013 -150.172544 67.250000... (5 Replies)
Discussion started by: handsonzhao
5 Replies

5. Shell Programming and Scripting

how to finding the exact pattern

I have a output like below: A1 B2 C1 D3 A12 B4 A14 I am trying to find A1 by using grep grep -i "A1" But I got (4 Replies)
Discussion started by: anupdas
4 Replies

6. Red Hat

finding exact version of Red Hat Linux

Hi, I would like to know how to find out exact version of linux on the basis of kernel level, uname -a 2.6.18-238.1.1.el5 from above command how to find out exact version of redhat linux? it is showing that version of redhat is 5.0 but it comes under which update like 1,2,3,4,5,6 ... (1 Reply)
Discussion started by: manoj.solaris
1 Replies

7. Shell Programming and Scripting

Finding the line with the exact same number

Hello All, What i am doing is , i tail a file from certain chatacter and then cat -n to get the line numbers.I search for a particular string and gets it line number. What i am interested in is the next line immediately after the pattern i search. But grep gives me result for all line... (5 Replies)
Discussion started by: kailash19
5 Replies

8. Shell Programming and Scripting

Finding exact match string

Hi All, I'm writing unix script, it should find exact matching in search string. Looks simple but when i started i'm stuck to find the exact match character string. The unix script reads the records from DB Table. The table will have values something likes these Feed : A Feed File name :... (3 Replies)
Discussion started by: luckybalaji
3 Replies

9. Shell Programming and Scripting

finding characters with new line

I have a file sample.txt with the below contents: Aaa - providioning add || dev - reeec dev kapl || ball - HERO || bal - provisioning pro || for given name i need the output to be the contents between - and || (excluding both) for eg : input - Aaa output -... (10 Replies)
Discussion started by: kinny
10 Replies

10. UNIX for Dummies Questions & Answers

Listing full file names with the exact length of 3 characters

This is what I have to do: Display the full file name (including the full path) and file size of all files whose name (excluding the path) is exactly 3 characters long. This is the code I have: find / -printf "Name: %f Path: %h Size: %s (bytes)\n" 2>/dev/null | grep -E "Name: .{3,} Path" |... (7 Replies)
Discussion started by: Joesgrrrl
7 Replies
Login or Register to Ask a Question