LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 04-12-2008, 05:55 PM   #1
swamprat
Member
 
Registered: Sep 2005
Location: New Jersey, (Which Exit), USA
Distribution: Centos 5 Under VMware in WinXP CentOS 5.3 all under VMware
Posts: 418

Rep: Reputation: 33
Find command, eliminating unwanted output


Hello all,

I using the follow command to find this IP any where in the system.

The command is working but produces unwanted output when the string isn't found.

My questions is this; howw can I eliminate the unwanted lines and only place the hits in a file.

rep: /home/rifkinho/.kde/share/apps/RecentDocuments/FDRPAS: No such file or directory
grep: and: No such file or directory
grep: FDRERASE.pdf[2].desktop: No such file or directory
/home/rifkinho/.kde/share/apps/RecentDocuments/.desktop:Name=https://216.254.113.27:10000
/home/rifkinho/.kde/share/apps/RecentDocuments/.desktop:URL=https://216.254.113.27:10000
grep: /home/rifkinho/.kde/share/apps/RecentDocuments/FDRPAS: No such file or directory

Just want the lines with the IP address to either appear and none of the junk and/or the lines with the IP address to go into a file.

Thanks.
 
Old 04-12-2008, 06:20 PM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,488

Rep: Reputation: 1077Reputation: 1077Reputation: 1077Reputation: 1077Reputation: 1077Reputation: 1077Reputation: 1077Reputation: 1077
Separate stdout and stderr - usually put the latter to /dev/null.
 
Old 04-12-2008, 06:36 PM   #3
swamprat
Member
 
Registered: Sep 2005
Location: New Jersey, (Which Exit), USA
Distribution: Centos 5 Under VMware in WinXP CentOS 5.3 all under VMware
Posts: 418

Original Poster
Rep: Reputation: 33
There is the exact command I'm using:

find / -type f | xargs grep '216\.254\.93\.22'

Separate stdout and stderr - usually put the latter to /dev/null.

How do set up what you said above?
 
Old 04-12-2008, 07:34 PM   #4
anupamsr
Member
 
Registered: Sep 2004
Location: India
Distribution: Kubuntu, Archlinux, Suse, Gentoo, Mandrake
Posts: 370

Rep: Reputation: 30
find / -type f 2>/dev/null | xargs grep '216\.254\.93\.22'
 
Old 04-13-2008, 05:31 PM   #5
swamprat
Member
 
Registered: Sep 2005
Location: New Jersey, (Which Exit), USA
Distribution: Centos 5 Under VMware in WinXP CentOS 5.3 all under VMware
Posts: 418

Original Poster
Rep: Reputation: 33
Thanks Anupamsr.

Could you please tell me what the '2' stands for?
 
Old 04-13-2008, 05:48 PM   #6
beadyallen
Member
 
Registered: Mar 2008
Location: UK
Distribution: Fedora, Gentoo
Posts: 209

Rep: Reputation: 36
The 2 represents stderr. So the command dumps the contents of the error stream to /dev/null. Usually, both stderr and stdout get sent to the console output, hence you were getting a mess.
 
Old 04-13-2008, 05:53 PM   #7
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,004
Blog Entries: 11

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
Um .... why not just a
egrep -rl '216\.254\.93\.22' /* 2>/dev/null



Cheers,
Tink
 
Old 04-13-2008, 07:28 PM   #8
anupamsr
Member
 
Registered: Sep 2004
Location: India
Distribution: Kubuntu, Archlinux, Suse, Gentoo, Mandrake
Posts: 370

Rep: Reputation: 30
Yes, that would be better. I never looked into grep too much myself...
 
  


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
find with -exec: no command output David the H. Linux - Software 5 01-03-2008 02:53 AM
how to redirect the output of find command to input of egrep babu198649 Linux - Newbie 2 12-27-2007 04:50 AM
How would I transfer the output of a command or a program to here, eliminating typin royeo Linux - Newbie 9 07-07-2006 10:09 PM
LXer: Six Approaches to Eliminating Unwanted E-Mail LXer Syndicated Linux News 1 05-24-2006 06:01 AM
how do i remove unwanted charaters at "script" command output? linuxzouk Linux - Newbie 4 05-15-2004 08:58 AM


All times are GMT -5. The time now is 11:46 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration