LinuxQuestions.org
Visit Jeremy's Blog.
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 03-24-2016, 03:26 PM   #1
abefroman
Senior Member
 
Registered: Feb 2004
Location: lost+found
Distribution: CentOS
Posts: 1,430

Rep: Reputation: 55
Is there a way to parse console notices from a command as output?


Is there a way to parse console notices from a command as output?

IE. to grep the output of ipcalc for bad, bad prints, but as you can see from wc -l, its not actually returning anything:
Code:
# ipcalc -c 192.168.0.h1 |grep bad |wc -l
ipcalc: bad IPv4 address: 192.168.0.h1
0
TIA
 
Old 03-24-2016, 03:46 PM   #2
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
Try checking whether the data is going to stdout or stderr??
 
Old 03-24-2016, 03:56 PM   #3
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
The error output is going to stderr.

If you want to merge stderr into stdout, you can use "2>&1", eg;
Code:
ipcalc -c 192.168.0.h1 2>&1 | grep bad | wc -l
 
Old 03-24-2016, 03:56 PM   #4
abefroman
Senior Member
 
Registered: Feb 2004
Location: lost+found
Distribution: CentOS
Posts: 1,430

Original Poster
Rep: Reputation: 55
Quote:
Originally Posted by grail View Post
Try checking whether the data is going to stdout or stderr??
It must be going to stderr, is there a way to get it to stdout? 3&>1 or something?
 
Old 03-24-2016, 03:57 PM   #5
abefroman
Senior Member
 
Registered: Feb 2004
Location: lost+found
Distribution: CentOS
Posts: 1,430

Original Poster
Rep: Reputation: 55
Quote:
Originally Posted by suicidaleggroll View Post
The error output is going to stderr.

If you want to merge stderr into stdout, you can use "2>&1", eg;
Code:
ipcalc -c 192.168.0.h1 2>&1 | grep bad | wc -l
Thanks, I was close, lol.
 
  


Reply



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
[SOLVED] Parse c external command output in real time szzed Programming 4 05-04-2012 01:48 PM
awk not parse the output of nc command! mythcat Linux - General 6 09-30-2011 03:00 AM
[shell script] execute command and parse output stoiss Programming 2 01-26-2009 01:49 AM
How do I parse the output of a command that output to standard out? gauol Programming 9 01-17-2008 01:54 PM
how to pipe and parse output of a command learnfast Linux - Newbie 2 06-15-2005 04:55 AM

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

All times are GMT -5. The time now is 01:24 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
Open Source Consulting | Domain Registration