The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
display warning messages on command line Danish Shakil Shell Programming and Scripting 2 02-22-2009 02:22 AM
Info req: /var/adm/messages - Kern.warning - different ID messages Petrucci SUN Solaris 1 12-04-2008 01:30 PM
grep exact string/ avoid substring search albertashish UNIX for Dummies Questions & Answers 3 11-03-2008 12:47 PM
Redirecting the warning messages. keka Shell Programming and Scripting 1 03-20-2007 05:11 AM
Telnet Server FTP warning messages 500 'AUTH GSSAPI' how to resolve?? csviking UNIX for Dummies Questions & Answers 0 07-10-2006 06:04 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-18-2009
shellscripter shellscripter is offline
Registered User
  
 

Join Date: Oct 2008
Location: chennai
Posts: 16
Exclamation How to avoid grep warning messages

Hi All,
When i try to grep for a patern in an directory, I am getting warning like "No such file or directory". Anyway script is working as expected. but i need to avoid this warning message.
Pass="`find . -type f | xargs grep 'test result - pass' | wc -l`"
grep: ./results/6052278-1-717520-HFR_QFTS_ALL.__taskid2.isis_test.Beginning: No such file or directory
grep: ISIS: No such file or directory
grep: config: No such file or directory
grep: load: No such file or directory
grep: ./results/6052278-1-717520-HFR_QFTS_ALL.__taskid2.isis_test.Beginning: No such file or directory
grep: interface%2Fbasic: No such file or directory
grep: pings%2Ftraceroute%2Fcontroller: No such file or directory
grep: check: No such file or directory

Thanks,
Parkkavan
  #2 (permalink)  
Old 03-18-2009
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,212
Redirect the output of stderr to /dev/null:

Code:
find . -type f | xargs grep 'test result - pass' 2>/dev/null | wc -l
  #3 (permalink)  
Old 03-18-2009
shellscripter shellscripter is offline
Registered User
  
 

Join Date: Oct 2008
Location: chennai
Posts: 16
Thanks Franklin. It works fine..

Can you tellme "2" mean in 2>/dev/null.

Thanks,
Parkkavan
  #4 (permalink)  
Old 03-18-2009
wireonfire wireonfire is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 19
2 by default is the file pointer for the error messages, 1 is that for stand output. Both go to screen by default. In this case you redirect error to /dev/null so you don't see them.
  #5 (permalink)  
Old 03-18-2009
shellscripter shellscripter is offline
Registered User
  
 

Join Date: Oct 2008
Location: chennai
Posts: 16
Thanks wireonfire for the explanation. :-)

Regards,
Parkkavan
  #6 (permalink)  
Old 03-18-2009
Mumford Mumford is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 2
You're seeing this because the find command passes the filenames it finds as a list of words separated by spaces. The problem is some of the files have spaces in the names. If you're on Linux or otherwise using GNU find & GNU xargs, you can use:

Code:
find . -type f -print0 | xargs -0 grep 'test result - pass' | wc -l
'print0' tells find to use \0 as the separator instead of space, and the -0 option to xargs tells it to accept \0 as the separator.

Last edited by Mumford; 03-18-2009 at 04:19 PM..
Sponsored Links
Closed Thread

Bookmarks

Tags
grep warning

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 06:52 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0