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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
08-06-2012, 11:54 AM
|
#1
|
LQ Newbie
Registered: Aug 2012
Posts: 5
Rep: 
|
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?
|
|
|
08-06-2012, 12:08 PM
|
#2
|
Member
Registered: Sep 2010
Distribution: Fedora, Android, CentOS
Posts: 91
Rep:
|
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:
What this does is call ldd and executes the which command as the input.
Give it a try.
|
|
|
08-06-2012, 12:09 PM
|
#3
|
LQ Veteran
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Rep: 
|
edit:
spazticclown types faster than I.
|
|
|
08-06-2012, 12:15 PM
|
#4
|
LQ Newbie
Registered: Aug 2012
Posts: 5
Original Poster
Rep: 
|
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?
|
|
|
08-06-2012, 01:58 PM
|
#5
|
Member
Registered: Sep 2010
Distribution: Fedora, Android, CentOS
Posts: 91
Rep:
|
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).
|
|
|
08-06-2012, 06:29 PM
|
#6
|
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.x
Posts: 18,434
|
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 02:59 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|