Bash: using commands as parameters (specifically cd, dirname and find)

Posted by sixtyfootersdude on Stack Overflow See other posts from Stack Overflow or by sixtyfootersdude
Published on 2010-03-15T18:44:33Z Indexed on 2010/03/16 14:51 UTC
Read the original article Hit count: 299

Filed under:
|
|
|
|

This command and output:

% find . -name file.xml 2> /dev/null
./a/d/file.xml
%

So this command and output:

% dirname `find . -name file.xml 2> /dev/null`
./a/d
%

So you would expect that this command:

% cd `dirname `find . -name file.xml 2> /dev/null``

Would change the current directory to ./a/d. Strangely this does not work. When I type cd ./a/d. The directory change works. However I cannot find out why the above does not work...

© Stack Overflow or respective owner

Related posts about unix

Related posts about bash