LinuxQuestions.org
Review your favorite Linux distribution.
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-28-2015, 03:25 AM   #1
apss_evaluator
Member
 
Registered: Mar 2012
Posts: 115

Rep: Reputation: Disabled
using awk print


Hi Linux Guru's

need some a little help regarding on the jboss command that will validate. The command should only echo either "jboss7" or "jboss4"


however in our jboss7 we got also jboss7modules running and it should not be there from the output

[pogi.ako@server2 ~]$ rpm -qa | grep jboss | grep -v config | awk -F'-' '{print $3}'
jboss7
jbossmodules


using with |tail -1 | head -1
[lemuel.luna@server2 ~]$ rpm -qa | grep jboss | grep -v config | awk -F'-' '{print $3}' |tail -1 | head -1
jbossmodules


but from other servers I see it has different approach

[pogi.ako@server1 bin]$ rpm -qa | grep jboss | grep -v config | awk -F'-' '{print $3}'
jbossmodules
jboss7


[pogi.ako@server1 bin]$ rpm -qa | grep jboss | grep -v config | awk -F'-' '{print $3}' |tail -1 | head -1
jboss7


I'm trying to achieve here on on not to include jbossmodules from the output
 
Old 03-28-2015, 03:41 AM   #2
apss_evaluator
Member
 
Registered: Mar 2012
Posts: 115

Original Poster
Rep: Reputation: Disabled
nevermind guys, this is now fixed
 
Old 03-28-2015, 04:10 AM   #3
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192
Even if you solve yourself, it is customary to supply the solution so others may benefit

I would add that there would be no reason to use grep at all if using awk and that if you simply include that there could be a number you would not get the modules output:
Code:
rpm -qa | awk -F- '/jboss[0-9]/{print $3}'
Above is untested but you should get the idea.
 
  


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] awk print dos not print text value jozelo Linux - Newbie 2 10-23-2013 04:37 AM
AWK Print order sec_tech Linux - Newbie 3 03-03-2013 09:26 PM
[SOLVED] help with awk-print please saeedamer Programming 6 03-16-2012 12:44 PM
[SOLVED] awk print only lines {not}containing FS grail Programming 8 04-12-2010 04:41 AM
How do I - not print - in awk? ZimMonkey Programming 10 08-21-2009 07:11 PM

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

All times are GMT -5. The time now is 09:47 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