LinuxQuestions.org
Help answer threads with 0 replies.
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 08-06-2012, 11:54 AM   #1
kostis*
LQ Newbie
 
Registered: Aug 2012
Posts: 5

Rep: Reputation: Disabled
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?
 
Old 08-06-2012, 12:08 PM   #2
spazticclown
Member
 
Registered: Sep 2010
Distribution: Fedora, Android, CentOS
Posts: 91
Blog Entries: 2

Rep: Reputation: 21
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)
What this does is call ldd and executes the which command as the input.

Give it a try.
 
Old 08-06-2012, 12:09 PM   #3
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
edit:
spazticclown types faster than I.
 
Old 08-06-2012, 12:15 PM   #4
kostis*
LQ Newbie
 
Registered: Aug 2012
Posts: 5

Original Poster
Rep: Reputation: Disabled
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?
 
Old 08-06-2012, 01:58 PM   #5
spazticclown
Member
 
Registered: Sep 2010
Distribution: Fedora, Android, CentOS
Posts: 91
Blog Entries: 2

Rep: Reputation: 21
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).
 
Old 08-06-2012, 06:29 PM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.x
Posts: 18,434

Rep: Reputation: 2790Reputation: 2790Reputation: 2790Reputation: 2790Reputation: 2790Reputation: 2790Reputation: 2790Reputation: 2790Reputation: 2790Reputation: 2790Reputation: 2790
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
PIPE questions for Linux 2.4 setup LittleBit17 Linux - General 0 05-21-2009 08:57 AM
Port redirection, iptables, apache questions? sarajevo Linux - Security 2 09-22-2006 06:02 AM
a few quick questions maybbach Linux - General 4 11-05-2004 03:14 AM

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

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