Piping output into a 2nd command
Posted on 2004-04-06
I'm trying to pipe the output of a find command into a 2nd command, which is to say that I want to cd over to the directory I already found with my find command, something like this:
find / -name mydir1 | cd $1
Does this work? Do I need to use a different variable substitution? What is the variable that indicates the piped in input? Also, What if I'm looking for an individual file, and I want to cd to it's parent directory, like this:
find / -name myfile1 | cd $1
I know that won't work, since it's sending a file, not a directory to cd, but how do I get only the file? Must I grep it out?