LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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, 04:26 PM   #1
abefroman
Senior Member
 
Registered: Feb 2004
Location: lost+found
Distribution: CentOS
Posts: 1,367

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, 04:46 PM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,243

Rep: Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684
Try checking whether the data is going to stdout or stderr??
 
Old 03-24-2016, 04:56 PM   #3
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,258

Rep: Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947
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, 04:56 PM   #4
abefroman
Senior Member
 
Registered: Feb 2004
Location: lost+found
Distribution: CentOS
Posts: 1,367

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, 04:57 PM   #5
abefroman
Senior Member
 
Registered: Feb 2004
Location: lost+found
Distribution: CentOS
Posts: 1,367

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


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


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