You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hadoop.apache.org by Pedro Sá da Costa <ps...@gmail.com> on 2012/10/22 11:09:25 UTC

What is the command to see if a file is a directory or not in HDFS from bash?

I execute  'hadoop-1.0.3/bin/hadoop dfs -test -d
/user/xeon/gutenberg/A.txt' command in the bash, and I was expecting
getting the value 0 or 1, but I got nothing.

What is the command to launch from the bash that allows to check if a
file in HDFS is a file or directory?

-- 
Best regards,

Re: What is the command to see if a file is a directory or not in HDFS from bash?

Posted by Andy Isaacson <ad...@cloudera.com>.
BTW, while verifying this behavior I noticed that there is a bug in
Hadoop 2.0 "dfs -test -d", it generates error messages when it should
be silent.  I filed the bug at

https://issues.apache.org/jira/browse/HDFS-4104

-andy

On Mon, Oct 22, 2012 at 2:57 PM, Andy Isaacson <ad...@cloudera.com> wrote:
> The result is reported in the shell exit code, not as a textual output
> from the command, just like the UNIX /usr/bin/test command.
>
> The intended use case is something like the following Bourne/bash shell example:
>
> if test -d /opt; then
>    ... install in /opt
> else
>    ... install in /usr
> fi
>
> or using the /usr/bin/[ synonym available on most systems,
>
> if [ -d /opt ]; then ...
>
> Similarly,
>
> if hadoop dfs -test -e something.txt; then
>    echo "something.txt exists on hdfs"
> else
>    echo "something.txt does not exist on hdfs"
> fi
>
> -andy
>
> On Mon, Oct 22, 2012 at 2:09 AM, Pedro Sá da Costa <ps...@gmail.com> wrote:
>> I execute  'hadoop-1.0.3/bin/hadoop dfs -test -d
>> /user/xeon/gutenberg/A.txt' command in the bash, and I was expecting
>> getting the value 0 or 1, but I got nothing.
>>
>> What is the command to launch from the bash that allows to check if a
>> file in HDFS is a file or directory?
>>
>> --
>> Best regards,

Re: What is the command to see if a file is a directory or not in HDFS from bash?

Posted by Andy Isaacson <ad...@cloudera.com>.
BTW, while verifying this behavior I noticed that there is a bug in
Hadoop 2.0 "dfs -test -d", it generates error messages when it should
be silent.  I filed the bug at

https://issues.apache.org/jira/browse/HDFS-4104

-andy

On Mon, Oct 22, 2012 at 2:57 PM, Andy Isaacson <ad...@cloudera.com> wrote:
> The result is reported in the shell exit code, not as a textual output
> from the command, just like the UNIX /usr/bin/test command.
>
> The intended use case is something like the following Bourne/bash shell example:
>
> if test -d /opt; then
>    ... install in /opt
> else
>    ... install in /usr
> fi
>
> or using the /usr/bin/[ synonym available on most systems,
>
> if [ -d /opt ]; then ...
>
> Similarly,
>
> if hadoop dfs -test -e something.txt; then
>    echo "something.txt exists on hdfs"
> else
>    echo "something.txt does not exist on hdfs"
> fi
>
> -andy
>
> On Mon, Oct 22, 2012 at 2:09 AM, Pedro Sá da Costa <ps...@gmail.com> wrote:
>> I execute  'hadoop-1.0.3/bin/hadoop dfs -test -d
>> /user/xeon/gutenberg/A.txt' command in the bash, and I was expecting
>> getting the value 0 or 1, but I got nothing.
>>
>> What is the command to launch from the bash that allows to check if a
>> file in HDFS is a file or directory?
>>
>> --
>> Best regards,

Re: What is the command to see if a file is a directory or not in HDFS from bash?

Posted by Andy Isaacson <ad...@cloudera.com>.
BTW, while verifying this behavior I noticed that there is a bug in
Hadoop 2.0 "dfs -test -d", it generates error messages when it should
be silent.  I filed the bug at

https://issues.apache.org/jira/browse/HDFS-4104

-andy

On Mon, Oct 22, 2012 at 2:57 PM, Andy Isaacson <ad...@cloudera.com> wrote:
> The result is reported in the shell exit code, not as a textual output
> from the command, just like the UNIX /usr/bin/test command.
>
> The intended use case is something like the following Bourne/bash shell example:
>
> if test -d /opt; then
>    ... install in /opt
> else
>    ... install in /usr
> fi
>
> or using the /usr/bin/[ synonym available on most systems,
>
> if [ -d /opt ]; then ...
>
> Similarly,
>
> if hadoop dfs -test -e something.txt; then
>    echo "something.txt exists on hdfs"
> else
>    echo "something.txt does not exist on hdfs"
> fi
>
> -andy
>
> On Mon, Oct 22, 2012 at 2:09 AM, Pedro Sá da Costa <ps...@gmail.com> wrote:
>> I execute  'hadoop-1.0.3/bin/hadoop dfs -test -d
>> /user/xeon/gutenberg/A.txt' command in the bash, and I was expecting
>> getting the value 0 or 1, but I got nothing.
>>
>> What is the command to launch from the bash that allows to check if a
>> file in HDFS is a file or directory?
>>
>> --
>> Best regards,

Re: What is the command to see if a file is a directory or not in HDFS from bash?

Posted by Andy Isaacson <ad...@cloudera.com>.
BTW, while verifying this behavior I noticed that there is a bug in
Hadoop 2.0 "dfs -test -d", it generates error messages when it should
be silent.  I filed the bug at

https://issues.apache.org/jira/browse/HDFS-4104

-andy

On Mon, Oct 22, 2012 at 2:57 PM, Andy Isaacson <ad...@cloudera.com> wrote:
> The result is reported in the shell exit code, not as a textual output
> from the command, just like the UNIX /usr/bin/test command.
>
> The intended use case is something like the following Bourne/bash shell example:
>
> if test -d /opt; then
>    ... install in /opt
> else
>    ... install in /usr
> fi
>
> or using the /usr/bin/[ synonym available on most systems,
>
> if [ -d /opt ]; then ...
>
> Similarly,
>
> if hadoop dfs -test -e something.txt; then
>    echo "something.txt exists on hdfs"
> else
>    echo "something.txt does not exist on hdfs"
> fi
>
> -andy
>
> On Mon, Oct 22, 2012 at 2:09 AM, Pedro Sá da Costa <ps...@gmail.com> wrote:
>> I execute  'hadoop-1.0.3/bin/hadoop dfs -test -d
>> /user/xeon/gutenberg/A.txt' command in the bash, and I was expecting
>> getting the value 0 or 1, but I got nothing.
>>
>> What is the command to launch from the bash that allows to check if a
>> file in HDFS is a file or directory?
>>
>> --
>> Best regards,

Re: What is the command to see if a file is a directory or not in HDFS from bash?

Posted by Andy Isaacson <ad...@cloudera.com>.
The result is reported in the shell exit code, not as a textual output
from the command, just like the UNIX /usr/bin/test command.

The intended use case is something like the following Bourne/bash shell example:

if test -d /opt; then
   ... install in /opt
else
   ... install in /usr
fi

or using the /usr/bin/[ synonym available on most systems,

if [ -d /opt ]; then ...

Similarly,

if hadoop dfs -test -e something.txt; then
   echo "something.txt exists on hdfs"
else
   echo "something.txt does not exist on hdfs"
fi

-andy

On Mon, Oct 22, 2012 at 2:09 AM, Pedro Sá da Costa <ps...@gmail.com> wrote:
> I execute  'hadoop-1.0.3/bin/hadoop dfs -test -d
> /user/xeon/gutenberg/A.txt' command in the bash, and I was expecting
> getting the value 0 or 1, but I got nothing.
>
> What is the command to launch from the bash that allows to check if a
> file in HDFS is a file or directory?
>
> --
> Best regards,

Re: What is the command to see if a file is a directory or not in HDFS from bash?

Posted by Andy Isaacson <ad...@cloudera.com>.
The result is reported in the shell exit code, not as a textual output
from the command, just like the UNIX /usr/bin/test command.

The intended use case is something like the following Bourne/bash shell example:

if test -d /opt; then
   ... install in /opt
else
   ... install in /usr
fi

or using the /usr/bin/[ synonym available on most systems,

if [ -d /opt ]; then ...

Similarly,

if hadoop dfs -test -e something.txt; then
   echo "something.txt exists on hdfs"
else
   echo "something.txt does not exist on hdfs"
fi

-andy

On Mon, Oct 22, 2012 at 2:09 AM, Pedro Sá da Costa <ps...@gmail.com> wrote:
> I execute  'hadoop-1.0.3/bin/hadoop dfs -test -d
> /user/xeon/gutenberg/A.txt' command in the bash, and I was expecting
> getting the value 0 or 1, but I got nothing.
>
> What is the command to launch from the bash that allows to check if a
> file in HDFS is a file or directory?
>
> --
> Best regards,

Re: What is the command to see if a file is a directory or not in HDFS from bash?

Posted by Andy Isaacson <ad...@cloudera.com>.
The result is reported in the shell exit code, not as a textual output
from the command, just like the UNIX /usr/bin/test command.

The intended use case is something like the following Bourne/bash shell example:

if test -d /opt; then
   ... install in /opt
else
   ... install in /usr
fi

or using the /usr/bin/[ synonym available on most systems,

if [ -d /opt ]; then ...

Similarly,

if hadoop dfs -test -e something.txt; then
   echo "something.txt exists on hdfs"
else
   echo "something.txt does not exist on hdfs"
fi

-andy

On Mon, Oct 22, 2012 at 2:09 AM, Pedro Sá da Costa <ps...@gmail.com> wrote:
> I execute  'hadoop-1.0.3/bin/hadoop dfs -test -d
> /user/xeon/gutenberg/A.txt' command in the bash, and I was expecting
> getting the value 0 or 1, but I got nothing.
>
> What is the command to launch from the bash that allows to check if a
> file in HDFS is a file or directory?
>
> --
> Best regards,

Re: What is the command to see if a file is a directory or not in HDFS from bash?

Posted by Andy Isaacson <ad...@cloudera.com>.
The result is reported in the shell exit code, not as a textual output
from the command, just like the UNIX /usr/bin/test command.

The intended use case is something like the following Bourne/bash shell example:

if test -d /opt; then
   ... install in /opt
else
   ... install in /usr
fi

or using the /usr/bin/[ synonym available on most systems,

if [ -d /opt ]; then ...

Similarly,

if hadoop dfs -test -e something.txt; then
   echo "something.txt exists on hdfs"
else
   echo "something.txt does not exist on hdfs"
fi

-andy

On Mon, Oct 22, 2012 at 2:09 AM, Pedro Sá da Costa <ps...@gmail.com> wrote:
> I execute  'hadoop-1.0.3/bin/hadoop dfs -test -d
> /user/xeon/gutenberg/A.txt' command in the bash, and I was expecting
> getting the value 0 or 1, but I got nothing.
>
> What is the command to launch from the bash that allows to check if a
> file in HDFS is a file or directory?
>
> --
> Best regards,