<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question HDFS command find argument type in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/HDFS-command-find-argument-type/m-p/324413#M229357</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For an application, I need to extract the maximum depth from an hdfs directory. I know how to do this action in shell: we can execute&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt; find /tmp -type d -printf '%d\n' | sort -rn | head -1&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So I wanted to do the same with the find function of hdfs:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;hdfs dfs -find /tmp -type d&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;but the -type argument does not exist on hdfs, here is the error:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;find: Unexpected argument: -type&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does anyone have any solution or advice for this problem ?&lt;/P&gt;
&lt;P&gt;ps: my hadoop version&amp;nbsp;Hadoop 2.6.0-cdh5.13.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;regards,&lt;/P&gt;
&lt;P&gt;thanks in advance&lt;/P&gt;</description>
    <pubDate>Thu, 16 Sep 2021 05:31:59 GMT</pubDate>
    <dc:creator>Ellyly</dc:creator>
    <dc:date>2021-09-16T05:31:59Z</dc:date>
    <item>
      <title>HDFS command find argument type</title>
      <link>https://community.cloudera.com/t5/Support-Questions/HDFS-command-find-argument-type/m-p/324413#M229357</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For an application, I need to extract the maximum depth from an hdfs directory. I know how to do this action in shell: we can execute&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt; find /tmp -type d -printf '%d\n' | sort -rn | head -1&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So I wanted to do the same with the find function of hdfs:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;hdfs dfs -find /tmp -type d&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;but the -type argument does not exist on hdfs, here is the error:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;find: Unexpected argument: -type&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does anyone have any solution or advice for this problem ?&lt;/P&gt;
&lt;P&gt;ps: my hadoop version&amp;nbsp;Hadoop 2.6.0-cdh5.13.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;regards,&lt;/P&gt;
&lt;P&gt;thanks in advance&lt;/P&gt;</description>
      <pubDate>Thu, 16 Sep 2021 05:31:59 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/HDFS-command-find-argument-type/m-p/324413#M229357</guid>
      <dc:creator>Ellyly</dc:creator>
      <dc:date>2021-09-16T05:31:59Z</dc:date>
    </item>
    <item>
      <title>Re: HDFS command find argument type</title>
      <link>https://community.cloudera.com/t5/Support-Questions/HDFS-command-find-argument-type/m-p/324436#M229364</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/71886"&gt;@Ellyly&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Here is the example.&lt;/P&gt;&lt;P&gt;(1). Firstly, list -R and grep "^d" to show all the subdirectories in your path:&lt;/P&gt;&lt;P&gt;# sudo -u hdfs hdfs dfs -ls -R /folder1/ | grep "^d"&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;drwxr-xr-x - hdfs supergroup 0 2021-09-15 14:48 /folder1/folder2&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;drwxr-xr-x - hdfs supergroup 0 2021-09-15 15:01 /folder1/folder2/folder3&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;drwxr-xr-x - hdfs supergroup 0 2021-09-15 15:01 /folder1/folder2/folder3/folder4&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;drwxr-xr-x - hdfs supergroup 0 2021-09-11 05:09 /folder1/subfolder1&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;(2). Then,&amp;nbsp;awk -F\/ '{print NF-1}' to calculate each directory's depth, actually we&amp;nbsp;&lt;SPAN&gt;print number of fields separated by /.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;After -F it is \ and /, no space in between, it is not character"V" !!! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;# sudo -u hdfs hdfs dfs -ls -R /folder1/ | grep "^d" | awk -F\/ '{print NF-1}'&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;2&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;3&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;4&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;2&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;(3). Finally, sort and head&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;# sudo -u hdfs hdfs dfs -ls -R /folder1/ | grep "^d" | awk -F\/ '{print NF-1}'|sort -rn|head -1&lt;BR /&gt;4&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Regards,&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Will&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;If the answer helps, please accept as solution and click thumbs up.&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Sep 2021 15:23:29 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/HDFS-command-find-argument-type/m-p/324436#M229364</guid>
      <dc:creator>willx</dc:creator>
      <dc:date>2021-09-15T15:23:29Z</dc:date>
    </item>
    <item>
      <title>Re: HDFS command find argument type</title>
      <link>https://community.cloudera.com/t5/Support-Questions/HDFS-command-find-argument-type/m-p/324607#M229418</link>
      <description>&lt;P&gt;Thanks &lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/82089"&gt;@willx&lt;/a&gt;, this solved my problem, work perfectly !!!&lt;/P&gt;</description>
      <pubDate>Fri, 17 Sep 2021 08:22:48 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/HDFS-command-find-argument-type/m-p/324607#M229418</guid>
      <dc:creator>Ellyly</dc:creator>
      <dc:date>2021-09-17T08:22:48Z</dc:date>
    </item>
  </channel>
</rss>

