LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Redirecting output to a command-line argument of another command (https://www.linuxquestions.org/questions/linux-newbie-8/redirecting-output-to-a-command-line-argument-of-another-command-292387/)

madiyaan 02-19-2005 04:29 PM

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

acid_kewpie 02-19-2005 04:35 PM

cat `locate file.txt`

or

cat $(locate file.txt)


All times are GMT -5. The time now is 04:33 PM.