Wednesday 23 March 2022

Hadoop: rm: remove a directory recursively

‘-R’ option is used to remove a directory recursively.

 

Syntax

hadoop fs -rm -R {directory_to_remove}

 

Let us experiment with an example.

$hadoop fs -ls -R /user/cloudera/dir1
-rw-r--r--   1 cloudera cloudera    9147128 2022-03-23 07:04 /user/cloudera/dir1/atlasClient.docx
drwxr-xr-x   - cloudera cloudera          0 2022-03-23 06:54 /user/cloudera/dir1/dir2
drwxr-xr-x   - cloudera cloudera          0 2022-03-23 07:23 /user/cloudera/dir1/dir2/dir3
-rw-r--r--   1 cloudera cloudera    6166736 2022-03-23 07:23 /user/cloudera/dir1/dir2/dir3/atlas.docx

 

Let’s delete the directory ‘/user/cloudera/dir1’ recursively and confirm the same.

$hadoop fs -rm -R /user/cloudera/dir1
Deleted /user/cloudera/dir1
$
$hadoop fs -ls -R /user/cloudera/dir1
ls: `/user/cloudera/dir1': No such file or directory
$

 


 

 

Previous                                                 Next                                                 Home

No comments:

Post a Comment