chaining multiple commands??
how do you pipe output from one command to another?
something like which mplayer | rpm -qf I am trying to find out which rpm mplayer belogns to.....but it doesn't work neither does which mplayer | rpm -qf - help..... |
you can rpm -qa|grep mplayer
|
or
rpm -qf $(which mplayer) if that's what u meant in ur post. |
Well I know this will work in this case. But I meant it as an example of how to use pipes to chain multiple commands. How do you do it in general though??
|
screwed up
|
You mean something like this?
<command> | <another command> ; <then do this command> | <yet another command> or <command> | <2nd command> | <3rd command> | <4th command> A good article about it: Linux and the Tools Philosophy |
Or do you mean:
<command> | <take output from last command as input for this command> output Cool |
that rpm -qa|grep mplayer
is a pipe. rpm -qa lists all the packages installed. here all that text is piped into grep which searches it for the word mplayer, then when mplayer is found, grep prints the line that it was found on. in general a program that can send a stream of text or bytes is sent to the input of another program that does something to that data. tar clfv - .|(cd /mnt/copy; tar xpf -) another example to look at |
Try this :
rpm -q -a | grep mplayer |
seeing as everyone else said exactly the same thing, i might as well
rpm -qa | grep mplayer :p it's also wrong... but nevermind. actually answering the question though, a program can only be used with a pipe if that is how it is written. while it could be designed for rpm to accept a file name through a pipe it is not particuarly useful, and so presumably no one bothered implementing it. personally in your example i would have said rpm -qf `which mplayer` but obviously that was only used as an example. you've got the right idea, it just isn't possible in that example. |
All times are GMT -5. The time now is 07:42 AM. |