I read that if you use the | command then it pipes the output of the first command to the input of the second,then why is it working?
Thank you!
find -size 1033c | cd
I read that if you use the | command then it pipes the output of the first command to the input of the second,then why is it working?
Thank you!
find -size 1033c | cd
The cd
command doesn't read standard input, so anything that you pipe to it will be ignored.
The closest to what your command is (literally) trying to do will be this:
cd `find -size 1033c`
... except that you are liable to 'cd' to a file (which will fail!) or not find a directory with that size ... leading to you (silently) cd-ing to the user's home directory.
And also your find
command is missing a directory to search!
Based on your comments, you are trying to cd
to the directory containing a file with a given size. If we can assume that there will only ever be one such file, then the following should work:
FILE=`find . -size 1033c -type f`
cd `dirname $FILE`
If there could be more than one match, then you need to do something like this ... which should cd to the directory with the first matching file.
FILE=`find . -size 1033c -type f -print -quit`
cd `dirname $FILE`