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 02-19-2005, 05:29 PM   #1
madiyaan
Member
 
Registered: Apr 2003
Posts: 69

Rep: Reputation: 15
Redirecting output to a command-line argument of another command


Hey all,
Please read through the entire problem before answering. Thanks.
I know that Linux allows you to redirect the standard output of a command to the standard input of another command using the pipe function (letter '|').
But what I want to do is use the standard output of a command as a COMMAND-LINE ARGUMENT of the other command.
Example:
locate abc.txt gives me this:
Code:
$ locate abc.txt
/home/madiyaan/dir1/dir2/dir3/abc.txt
Now I want to be able to use this as the command line argument (as opposed to, say, copy and pasting) of another command like cat.

Code:
$ cat some_stuff_goes_here_for_redirection locate abc.txt
This will save me a lot of copy and pasting. Please tell me a way to do this in just one line.
Thanks,
Madiyaan
 
Old 02-19-2005, 05:35 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,414

Rep: Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967
cat `locate file.txt`

or

cat $(locate file.txt)
 
  


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
Is there a single command to list all hardware installed (command line)? davee Linux - Hardware 6 02-28-2009 08:19 PM
Shell Scripting - use the output of a command as an argument for another timgiffney Programming 6 04-17-2006 12:13 PM
Command line to get output on a file satimis Programming 4 06-24-2005 07:04 AM
Redirecting output of running command tommyr1216 Linux - General 3 03-04-2005 09:20 PM
Command to output file content line by line aznluvsmc Programming 2 09-12-2004 08:45 PM


All times are GMT -5. The time now is 02:42 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration