Link to home
Start Free TrialLog in
Avatar of jedblack
jedblack

asked on

feed output of command to another command within the same prompt line?

hi all,

i'm sure this is simple, but i cant figure it out...

I am doing an rpm search for gdb and its giving me a couple entries, I tail the entries to give me one result.  Instead of copy/paste the result into another rpm command, I just want to feed/append it to a command within the same line in the prompt...

for example, i get this...

[root@build ~]# rpm -qa|grep -i gdb|tail -1
gdb-7.1-29.el6_0.1.x86_64
[root@build ~]#


i was to do something like this...
[root@build ~]# rpm -qa|grep -i gdb|tail -1 >> rpm -ql


I just cant remember how...really dont want to instantiate a variable to hold the output, there must be some redirection kung-fu i'm forgetting...
Avatar of ozo
ozo
Flag of United States of America image

do you mean
rpm -qa|grep -i gdb|tail -1|rpm -ql
or something else?
or do you mean
rpm -ql `rpm -qa|grep -i gdb|tail -1`
As Ozo has put it
rpm -ql $(rpm -qa|grep -i gdb|tail -1)

But it would depend upon your macro settings whether this command would be successful or not.  You may need to chop off a part of RPM name for query ql to run
Avatar of jedblack
jedblack

ASKER

@ozo..

not quite...

its a little backwards, i would like to just work in sequence by sending the output to rpm -qa without having to fork off with backticks...
ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
@ozo,

Thanks, exactly what i wanted...dint even think about xargs/exec -- the other way works just fine - but just a PITA -- you do an rpm -qa grep something, then tail it and then realize you have to put something in front of it and wrap the previous stuff in backticks..etc... just so much faster IMO to throw something on the end like with xargs...

thanks !