LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-25-2010, 05:59 PM   #1
bluethundr
Member
 
Registered: Jun 2003
Location: Summit, NJ
Distribution: CentOS 5.4
Posts: 144

Rep: Reputation: 15
grep the contents of a file with another file


someone once told me that use can pass a file to grep and use that to search the contents of another file.

if that is the case I'm not entirely sure why the following isn't working for me.

Code:
[root@LCENT01:~]#grep -i id_rsa.pub .ssh/authorized_keys 
[root@LCENT01:~]#cat id_rsa.pub >> .ssh/authorized_keys 
[root@LCENT01:~]#grep -i id_rsa.pub .ssh/authorized_keys
thanks in advance!
 
Old 09-25-2010, 06:04 PM   #2
fuubar2003
Member
 
Registered: May 2004
Location: Orlando, Florida
Distribution: SLES10/11, RH4/5 svrs, Fedora, Debian/Ubuntu/Mint; FreeBSD/OpenBSD
Posts: 63

Rep: Reputation: 26
Code:
grep -f <filename> <filenameyouaresearching>
...is that what yer lookin for?

From 'grep --help':

-f, --file=FILE obtain PATTERN from FILE
 
Old 09-26-2010, 12:24 AM   #3
bluethundr
Member
 
Registered: Jun 2003
Location: Summit, NJ
Distribution: CentOS 5.4
Posts: 144

Original Poster
Rep: Reputation: 15
Talking done!!

Quote:
Originally Posted by fuubar2003 View Post
Code:
grep -f <filename> <filenameyouaresearching>
...is that what yer lookin for?

From 'grep --help':

-f, --file=FILE obtain PATTERN from FILE
Yep that did it!!! thanks!!
 
Old 09-26-2010, 01:24 AM   #4
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
Please mark as SOLVED when you have a solution.
 
  


Reply

Tags
bash, grep



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
grep contents of file on remote server bluethundr Linux - Newbie 5 09-25-2010 11:09 AM
How do you overwrite the contents of a file without changing the file size? lothario Linux - Software 3 07-13-2010 08:43 AM
sed -- replacing a string in a file with the contents of another file? CGP314 Linux - Newbie 10 06-17-2010 04:29 PM
how to append contents of one file to another existing file amit_pansuria Programming 1 11-17-2008 10:01 AM
Bash remove part of a file based on contents of another file bhepdogg Programming 4 01-31-2007 03:13 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:45 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration