Return-Path: X-Original-To: apmail-hadoop-hdfs-user-archive@minotaur.apache.org Delivered-To: apmail-hadoop-hdfs-user-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 51F8DDC1E for ; Mon, 22 Oct 2012 22:02:50 +0000 (UTC) Received: (qmail 25725 invoked by uid 500); 22 Oct 2012 22:02:45 -0000 Delivered-To: apmail-hadoop-hdfs-user-archive@hadoop.apache.org Received: (qmail 25351 invoked by uid 500); 22 Oct 2012 22:02:45 -0000 Mailing-List: contact user-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@hadoop.apache.org Delivered-To: mailing list user@hadoop.apache.org Received: (qmail 25344 invoked by uid 99); 22 Oct 2012 22:02:45 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 22 Oct 2012 22:02:45 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of adi@cloudera.com designates 209.85.223.176 as permitted sender) Received: from [209.85.223.176] (HELO mail-ie0-f176.google.com) (209.85.223.176) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 22 Oct 2012 22:02:40 +0000 Received: by mail-ie0-f176.google.com with SMTP id k11so5068134iea.35 for ; Mon, 22 Oct 2012 15:02:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding:x-gm-message-state; bh=pIpCu4I3vKLJsnYRHRXDL982DEN8ahWVd3tdULgmd4k=; b=icb79JINSckQeoqXkf4Q7Wjem1/7wd8xwIVvZ9YvKznP8imk4giTNl+QbBGVi6k8xo bfCVF5oxnW+GP67/FeUNu3RYbJPwzjQDubuUBDYVlRBJhI+dxk4hOoAmaHQkzUetVx12 OYzBbe/deHWNLMTK3xrP2lR+mhX4ZJ1PKJ7DxoWcCeA8iL98wWkJ2X041VHi72Y1cdHk jbQaTPGAUufRdwNanBQKH15y88JJBJxh6sPrslxr67nljDAHF8FlN3x1KJ8aNfCVIDVg WpOkJWOleg1Qh3N84rn3o3UWz6tGXgmGQ55nJMU+fqOzYksMxT4JHwY2wmKGQUUwdoyP 5Wog== MIME-Version: 1.0 Received: by 10.50.40.133 with SMTP id x5mr18075326igk.32.1350943340193; Mon, 22 Oct 2012 15:02:20 -0700 (PDT) Received: by 10.64.124.3 with HTTP; Mon, 22 Oct 2012 15:02:20 -0700 (PDT) In-Reply-To: References: Date: Mon, 22 Oct 2012 15:02:20 -0700 Message-ID: Subject: Re: What is the command to see if a file is a directory or not in HDFS from bash? From: Andy Isaacson To: user@hadoop.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Gm-Message-State: ALoCoQlCFSnZLeA8zzWLLDChj/uPdKDy7A0uvK5bC9Ef69pux/ctrsZpUlK5cVRHMxxfDlB/P9+7 X-Virus-Checked: Checked by ClamAV on apache.org 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 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 e= xample: > > 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=E1 da Costa = 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,