views:

68

answers:

3

i want to ask if i can execute command within command ...or use the output of the previous command as the input of the followed command : command x then command y in command y i want use output of command x

A: 
Colin Hebert
please you can give me example in more detail
Osama Ahmad
but please in the following case what is the solution : i execute "find / -type f -name fs-type -print " this commad found all repository ... now i need to find all directory of repository by this command "svnlook tree /var/lib/lib.org.15-01-2008/svn/repos/pstest | egrep "/$
Osama Ahmad
Then you need to look at the `-exec` option of find
Colin Hebert
A: 

You can do something like;

x=$(grep $(dirname "$path") file)

here dirname "$path" will run first and its result will be substituted and then grep will run, searching for the result of dirname in the file

codaddict
but please in the following case what is the solution : i execute "find / -type f -name fs-type -print " this commad found all repository ... now i need to find all directory of repository by this command "svnlook tree /var/lib/lib.org.15-01-2008/svn/repos/pstest | egrep "/$ ..... how i can solve it
Osama Ahmad
@Mohammed: Add that to your main question.
Donal Fellows
i want to find all my repository and then find its entire content
Osama Ahmad
+1  A: 

What exactly are you trying to do? It's not clear from the commands you are executing. Perhaps if you describe what you're looking for we can point you in the right direction. If you want to execute a command over a range of file (or directory) names returned by the "find" command, Colin is correct, you need to look at the "-exec" option of "find". If you're looking to execute a command over a bunch of arguments listed in a file or coming from stdin, you need to check out the "xargs" commands. If you want to put the output of a single command on to the command line of another command, then using "$(command)" (or 'command' [replace the ' with a backquote]) will do the job. There's a lot of ways to do this, but without knowing what it is you're trying it's hard to be more helpful.

Jim Nutt