Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]
Created 11-16-2017 11:23 AM
What does hadoop fs -test do?
What are the other set of options which can be used along with -test like hadoop fs -test -d.
Created 11-16-2017 12:12 PM
hadoop fs has been deprecated, From hadoop 2.0 use hdfs dfs instead.Having said that hadoop fs -test -[defsz] URI is used to check the hdfs and it takes the below options:
-d: f the path is a directory, return 0. -e: if the path exists, return 0. -f: if the path is a file, return 0. -s: if the path is not empty, return 0. -z: if the file is zero length, return 0.
Example
Check for valid directories in hdfs
$ hdfs dfs -ls / Found 7 items drwxrwx--- - ambari-qa hdfs 0 2017-10-19 14:13 /user/ambari-qa drwxr-xr-x - druid hdfs 0 2017-10-19 20:49 /user/druid drwxr-xr-x - hbase hdfs 0 2017-10-19 13:43 /user/hbase drwxr-xr-x - hcat hdfs 0 2017-10-19 13:53 /user/hcat drwxr-xr-x - hive hdfs 0 2017-10-19 13:53 /user/hive drwxrwxr-x - oozie hdfs 0 2017-10-19 13:57 /user/oozie drwxr-xr-x - zeppelin hdfs 0 2017-10-19 19:25 /user/zeppelin
Test whether path exists,the below returns 0
$ hdfs dfs -test -e /user/druid
Hope that helps
Created 11-16-2017 12:12 PM
hadoop fs has been deprecated, From hadoop 2.0 use hdfs dfs instead.Having said that hadoop fs -test -[defsz] URI is used to check the hdfs and it takes the below options:
-d: f the path is a directory, return 0. -e: if the path exists, return 0. -f: if the path is a file, return 0. -s: if the path is not empty, return 0. -z: if the file is zero length, return 0.
Example
Check for valid directories in hdfs
$ hdfs dfs -ls / Found 7 items drwxrwx--- - ambari-qa hdfs 0 2017-10-19 14:13 /user/ambari-qa drwxr-xr-x - druid hdfs 0 2017-10-19 20:49 /user/druid drwxr-xr-x - hbase hdfs 0 2017-10-19 13:43 /user/hbase drwxr-xr-x - hcat hdfs 0 2017-10-19 13:53 /user/hcat drwxr-xr-x - hive hdfs 0 2017-10-19 13:53 /user/hive drwxrwxr-x - oozie hdfs 0 2017-10-19 13:57 /user/oozie drwxr-xr-x - zeppelin hdfs 0 2017-10-19 19:25 /user/zeppelin
Test whether path exists,the below returns 0
$ hdfs dfs -test -e /user/druid
Hope that helps
Created 11-16-2017 01:13 PM
Thanks @Geoffrey Shelton Okot. This is what I'm looking for.
Created 11-16-2017 12:15 PM