LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
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 08-19-2011, 05:14 AM   #1
alancampbell6
LQ Newbie
 
Registered: Jul 2011
Posts: 16

Rep: Reputation: Disabled
Grep another grep's output


>>grep -Fxvf Thu.txt Fri.txt
mac132
mac288
mac778
>>grep -e `grep -Fxvf Thu.txt Fri.txt` Fri.xls | awk '{print $1,$2,$3}'
grep: mac288: No such file or directory
grep: mac778: No such file or directory
Fri.xls:mac132 10.32.107.145 airport


As you can see the first grep outputs three results. I want to grep these three results in a text file but as you can see it doesnt really work. Anyone know how to get this working?
 
Old 08-19-2011, 05:42 AM   #2
mayursingru
Member
 
Registered: Nov 2010
Location: Pune
Distribution: CentOS
Posts: 51

Rep: Reputation: 5
Hi,
What are the contents of the two files "Thu.txt, Fri.txt" .
 
Old 08-19-2011, 07:44 AM   #3
16pide
Member
 
Registered: Jan 2010
Posts: 418

Rep: Reputation: 83
Quote:
Grep another grep's output
I'm not sure exactly what you're trying to achieve, but why not just pipe one grep command into another grep command?
for example:
Code:
ls -l|grep .mp3|grep 2011|grep -v georges
 
Old 08-19-2011, 08:20 AM   #4
EmaRsk
Member
 
Registered: Mar 2006
Distribution: Funtoo
Posts: 124

Rep: Reputation: 25
Code:
for line in $(grep -Fxvf Thu.txt Fri.txt); do
    grep -e $line Fri.xls | awk '{print $1,$2,$3}'
done
 
1 members found this post helpful.
Old 08-19-2011, 10:49 AM   #5
alancampbell6
LQ Newbie
 
Registered: Jul 2011
Posts: 16

Original Poster
Rep: Reputation: Disabled
Thank you EmaRsk works perfect
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
using grep to output non-matches into output file binny959 Linux - General 5 12-25-2010 12:20 AM
Trying to understand pipes - Can't pipe output from tail -f to grep then grep again lostjohnny Linux - Newbie 15 03-12-2009 11:31 PM
Grep on output of command returns all output traigo Linux - Newbie 2 02-24-2009 06:15 PM
ps -eH | grep java output in a active passive clustered output johnkalikavunkal Linux - Server 2 01-31-2009 12:21 AM
grep output on stdout and grep output to file don't match xnomad Linux - General 3 01-13-2007 05:56 AM


All times are GMT -5. The time now is 10:13 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration