question using grep with files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting question using grep with files
# 1  
Old 03-02-2009
question using grep with files

hi,

i'm trying to figure out how to use grep in different ways in bash..

lets say you have two files, one with a list of words and the other with text

i want to go through the list of words in one file and for each word, find every occurrence of that word in the other file and display that entire line

i was playing around with diff but can't seem to figure this one out..

can anyone help me out please?

thanks in advance
# 2  
Old 03-02-2009
Code:
grep -f listofwords.txt  bigfile.txt

You need to read the man pages or info pages on grep.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

General find /grep question: files with lines ending in r

I am trying to find files that have lines in them that end in an r. I have been able to locate files by using the following command: find . -type f -name "*RECORDS"| xargs grep -l r$ However, I now want to find files that don't end in r anywhere. That means that no sentences or lines in... (9 Replies)
Discussion started by: newbie2010
9 Replies

2. UNIX for Dummies Questions & Answers

Grep question

Guys, I'm a newbie for UNIX. I want to grep the last characters after the last "-" sign. eg: abcd-231-1-44 abcd-2341-22-55 abcd-1-23-6 In the above example. I want to grep just the last characters after the 3rd "-" sign. line1 it will be 44. line2 55 and line3 6 TIA (4 Replies)
Discussion started by: miltonrods
4 Replies

3. Shell Programming and Scripting

grep for certain files using a file as input to grep and then move

Hi All, I need to grep few files which has words like the below in the file name , which i want to put it in a file and and grep for the files which contain these names and move it to a new directory , full file name -C20091210.1000-20091210.1100_SMGBSC3:1000... (2 Replies)
Discussion started by: anita07
2 Replies

4. UNIX for Dummies Questions & Answers

Another grep question

Hi guys, I'm very new to unix but am liking it a lot so far, so please be gentle on this newb. I tried using the search for this question, but no luck. Anyways, i've got a few data fields... for example John Adress1 Adress2 Sam Adress3 Adress4 Jason Adress5 Adress6 Is... (4 Replies)
Discussion started by: Uss_Defiant
4 Replies

5. Shell Programming and Scripting

Question of grep

As i understand the filter process of grep i was wondering, is it possible to to have a hidden word in a file(eg ------) and then use the grep filter to find a specific letter in that word which you can then replace with the letter in that word (eg ---a--) if it is please show me an example if it... (6 Replies)
Discussion started by: ZAXTHEGREAT
6 Replies

6. Shell Programming and Scripting

grep question

hello people, All my servers have 4 mounts with this norme. For example, if my hostname is siroe. df -h | grep `hostname` /dev/dsk/c1t3d0s6 404G 399G 800M 100% /siroe3 /dev/dsk/c1t2d0s6 404G 399G 800M 100% /siroe2 /dev/md/dsk/d6 20G 812M 19G ... (3 Replies)
Discussion started by: melanie_pfefer
3 Replies

7. UNIX for Dummies Questions & Answers

grep -f question

when using grep -f file1 file2 if you have multiple entries in the pattern file1 that are the same will it take the line out of file2 that matches file1 each time it comes up? if not by default can you set a flag to make this possible? or another way - can you get it to search for and match the... (8 Replies)
Discussion started by: Adriel
8 Replies

8. UNIX for Dummies Questions & Answers

Question about GREP

I have 2 files, in one file is a list of hex numbers, the other is what i need matched. Is it possible for me to specify to grep the list and have it go through the second file for each item in the list in the first file to match the lines? so this is like a cross-refference. (16 Replies)
Discussion started by: Adriel
16 Replies

9. UNIX for Dummies Questions & Answers

Grep Question

Hello Everybody, I have files; yyyymmdd.log which the data look like this; "Txid=9426043&MsgTxt=Thankyou&UserId=john&Password=jh2501" "Txid=9426150&MsgTxt=Thankyou&UserId=john&Password=jh2501" . . . "Txid=9426200&MsgTxt=Thankyou&UserId=john&Password=jh2501" Question 1: How to... (3 Replies)
Discussion started by: nazri76
3 Replies

10. UNIX for Dummies Questions & Answers

Grep question

sometimes I'll do a search with grep and it just goes down a line and hangs. What is it doing? (4 Replies)
Discussion started by: eloquent99
4 Replies
Login or Register to Ask a Question