Quick questions about pipe redirection
Hi!
I've been reading a bit about bash and came upon the ldd command. I thought I'd try it with vlc to see the dependencies. Of course I needed the path to the vlc executable first, which i got with "which vlc". This outputs "/usr/bin/vlc" as a string that I could type (or copy) as an argument to ldd. Then I thought, why should I go through the trouble and not use "which vlc|ldd" instead? After all isn't this what pipe redirection is for; Passing the output of the first command as an argument to the second? I also tried "which vlc|ldd -" but that didn't work either. Am I missing something or is it just that ldd doesn't work that way? |
The program has to be capable of receiving the information from the pipe. It looks to me (through basic testing) that ldd doesn't like that.
However this should work: Code:
ldd $(which vlc) Give it a try. |
edit:
spazticclown types faster than I. |
Thanks for the quick replies. I hadn't thought of this approach. It works indeed, and so does "ldd `which vlc`" which also executes the command and feeds the result to ldd. Is there an advantage to one approach or the other or is it just a matter of preference?
|
The method with `` is the first method I learned and works fine for everything I have done. With $(), from my understanding, is a more recent way of doing it and is a lot easier to see what is going on when scanning large amounts of code, however it may only work in bash or korn shells.
If anybody has more info on this than I can provide I would be interested in it as well (links etc). |
Basically, the backquote method `` is the original style on Unix eg BSD, Solaris, HP-UX, AIX etc.
The $() is newer and I think(?) probably only since the later version of ksh or possibly since the advent of Linux. Its as well to recognise both if you work in the commercial environment. |
All times are GMT -5. The time now is 03:51 AM. |