Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 07-31-2013, 11:14 AM   #1
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, 11:24 AM   #2
Registered: Oct 2012
Distribution: OpenSuSE,RHEL,Fedora,OpenBSD
Posts: 982
Blog Entries: 2

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

Rep: Reputation: 444Reputation: 444Reputation: 444Reputation: 444Reputation: 444
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, 08:10 PM   #4
LQ Newbie
Registered: Feb 2013
Location: China
Posts: 29

Original Poster
Rep: Reputation: Disabled


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

All times are GMT -5. The time now is 07:27 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration