LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 07-31-2013, 10:14 AM   #1
zousheng
LQ Newbie
 
Registered: Feb 2013
Location: China
Posts: 29

Rep: Reputation: Disabled
why java -version | grep 1.6 doesn't work as expected


Hi ,

Today just met this issue, running java -version | grep 1.6, this doesn't work as expected, just display all the information,
after running java -version >1.txt 2>2.txt , found the outout is in 2.txt, the standard error output. Don't know how it works. please help
 
Old 07-31-2013, 10:24 AM   #2
linosaurusroot
Member
 
Registered: Oct 2012
Distribution: OpenSuSE,RHEL,Fedora,OpenBSD
Posts: 982
Blog Entries: 2

Rep: Reputation: 244Reputation: 244Reputation: 244
Code:
java -version 2>&1 | grep "1\.6"
 
Old 07-31-2013, 10:27 AM   #3
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian sid
Posts: 2,683

Rep: Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783Reputation: 783
java is sending the 'info' to stderr,

if you want 'grep it', you need to redirect stderr to stdout

java -version 2>&1 | grep 1.6
 
Old 07-31-2013, 07:10 PM   #4
zousheng
LQ Newbie
 
Registered: Feb 2013
Location: China
Posts: 29

Original Poster
Rep: Reputation: Disabled
thanks.
 
  


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] keyboard doesn't work as expected hua Solaris / OpenSolaris 13 06-03-2013 07:56 AM
iptables doesn't work as expected rluo Red Hat 3 01-18-2013 12:34 AM
Subwoofer doesn't work as expected Kubuntu Linux - Hardware 0 06-20-2012 03:23 PM
Crond script doesn't work as expected Karimo Slackware 1 02-14-2010 06:32 PM
iptables rules doesn't work as expected.. Shioni Linux - Security 4 11-15-2006 01:37 AM

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

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