You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-user@hadoop.apache.org by Santiago Pérez <el...@gmail.com> on 2010/03/30 17:24:30 UTC

Listing subdirectories in Hadoop

Hej

I've checking the API and on internet but I have not found any method for
listing the subdirectories of a given directory in the HDFS. 

Can anybody show me how to get the list of subdirectories or even how to
implement the method? (I guess that it should be possible and not very
hard).

Thanks in advance ;)
-- 
View this message in context: http://old.nabble.com/Listing-subdirectories-in-Hadoop-tp28084164p28084164.html
Sent from the Hadoop core-user mailing list archive at Nabble.com.


Re: Listing subdirectories in Hadoop

Posted by biblio84 <fa...@gmail.com>.
Hi, 

You can list all subdirectories following method: [Assuming that u r in ur
hadoop install directory]
bin/hadoop fs -lsr {Directory_to_list_the_contents}
-- 
View this message in context: http://old.nabble.com/Listing-subdirectories-in-Hadoop-tp28084164p28939645.html
Sent from the Hadoop core-user mailing list archive at Nabble.com.


Re: Listing subdirectories in Hadoop

Posted by A Levine <le...@gmail.com>.
If you were talking about looking at directories within a Java
program, here is what has worked for me.

FileSystem fs;
FileStatus[] fileStat;
Path[] fileList;
SequenceFile.Reader reader = null;
try{
     // connect to the file system
     fs = FileSystem.get(conf);

     // get the stat on all files in the source directory
     fileStat = fs.listStatus(sourceDir);
			
     // get paths to the files in the source directory
     fileList = FileUtil.stat2Paths(fileStat);

    // then you can do something like
    for(int x = 0; x < fileList.length; x++){
         System.out.println(x + " " + fileList[x]);
    }
} catch(IOException ioe){
    // do something
}

Hope this helps.

andrew

--

On Tue, Mar 30, 2010 at 11:54 AM, Ted Yu <yu...@gmail.com> wrote:
> Does this get what you want ?
> hadoop dfs -ls <path> | grep drwx
>
> On Tue, Mar 30, 2010 at 8:24 AM, Santiago Pérez <el...@gmail.com> wrote:
>
>>
>> Hej
>>
>> I've checking the API and on internet but I have not found any method for
>> listing the subdirectories of a given directory in the HDFS.
>>
>> Can anybody show me how to get the list of subdirectories or even how to
>> implement the method? (I guess that it should be possible and not very
>> hard).
>>
>> Thanks in advance ;)
>> --
>> View this message in context:
>> http://old.nabble.com/Listing-subdirectories-in-Hadoop-tp28084164p28084164.html
>> Sent from the Hadoop core-user mailing list archive at Nabble.com.
>>
>>
>

Re: Listing subdirectories in Hadoop

Posted by Ted Yu <yu...@gmail.com>.
Does this get what you want ?
hadoop dfs -ls <path> | grep drwx

On Tue, Mar 30, 2010 at 8:24 AM, Santiago Pérez <el...@gmail.com> wrote:

>
> Hej
>
> I've checking the API and on internet but I have not found any method for
> listing the subdirectories of a given directory in the HDFS.
>
> Can anybody show me how to get the list of subdirectories or even how to
> implement the method? (I guess that it should be possible and not very
> hard).
>
> Thanks in advance ;)
> --
> View this message in context:
> http://old.nabble.com/Listing-subdirectories-in-Hadoop-tp28084164p28084164.html
> Sent from the Hadoop core-user mailing list archive at Nabble.com.
>
>