LinuxQuestions.org
Review your favorite Linux distribution.
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 11-13-2010, 03:49 PM   #1
raviluchmun
LQ Newbie
 
Registered: Nov 2010
Posts: 2

Rep: Reputation: 0
use output of previous command as parameter to another command


Hello,
I want to use the output of a previous command as a parameter to another command.
For example:
to know where "nice" is stored i typed:
which nice
output: /usr/bin/nice

now the second command i typed is:
ls -l /usr/bin/nice

Is there a way to have a single command like:
ls -l which nice ?

thanks
 
Old 11-13-2010, 03:53 PM   #2
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,130
Blog Entries: 2

Rep: Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825
Just put the command in backticks:
Code:
ls -l `which nice`
 
1 members found this post helpful.
Old 11-13-2010, 03:53 PM   #3
gdejonge
Member
 
Registered: Aug 2010
Location: Netherlands
Distribution: Kubuntu, Debian, Suse, Slackware
Posts: 317

Rep: Reputation: 73
The simpliest methods is using backquotes around a command.
Something like this:
Quote:
gerrard@orion:~$ ls -l `which nice`
-rwxr-xr-x 1 root root 39376 2010-09-21 20:32 /usr/bin/nice
 
1 members found this post helpful.
Old 11-13-2010, 03:57 PM   #4
raviluchmun
LQ Newbie
 
Registered: Nov 2010
Posts: 2

Original Poster
Rep: Reputation: 0
thank you to both of you
 
Old 11-14-2010, 01:35 AM   #5
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
If you do it often a function defined in ~/.bashrc would be convenient:
Code:
function wl {
    ls -l "$( which "$1" )"
}
 
  


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
[SOLVED] redirecting STDOUT of previous command to STDIN of next command urban.yoga.journeys Linux - General 9 11-22-2009 04:16 AM
How to pipe output to another command parameter? FireRaven Linux - Newbie 2 07-20-2009 08:44 AM
[SOLVED] append command output to file by giving command in terminal sumeet inani Linux - Newbie 4 07-03-2009 11:36 AM
how to get the absolute path information of a command from ps command output ratul_11 Linux - General 1 08-06-2008 03:10 AM
Redirecting output to a command-line argument of another command madiyaan Linux - Newbie 1 02-19-2005 05:35 PM


All times are GMT -5. The time now is 08:17 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration