![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Counting the number of occurances of all characters (a-z) in a string | rsendhilmani | Shell Programming and Scripting | 5 | 08-05-2008 09:10 AM |
| Counting files in one directory | matrixtlm | UNIX for Dummies Questions & Answers | 10 | 06-15-2007 04:14 PM |
| Help with counting files please | gerard1 | Shell Programming and Scripting | 6 | 09-25-2006 10:37 AM |
| Counting lines and files | jorge.ferreira | UNIX for Dummies Questions & Answers | 6 | 12-11-2003 08:24 AM |
| counting files | Edy | UNIX for Dummies Questions & Answers | 5 | 06-28-2001 08:26 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
I have two files I want to compare, one is a list of variables and the other is a text file COBOL program.
Basically what I want to do is display only those variables that appear in the COBOL program only once. However I would also accept a count of each variable as it appears in the COBOL program. fgrep –f VAR TEST.CBL will display the lines of the code that match the variable file, however what I need is to locate those variables that have only one match. Any ideas? |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
I dont think you can do it directly with grep. How about:
Code:
#!/bin/ksh
for f in `cat VAR`
do
COUNT=`grep $f TEST.CBL | wc -l`
if [[ $COUNT -eq 1 ]]
then
echo $f
fi
done
|
|
#3
|
|||
|
|||
|
Works great!
Thank you PxT! |
|||
| Google The UNIX and Linux Forums |