![]() |
| Implement .add .retrieve .delete tasks in Hadoop | IndianTechnoEra |
Aim: Implement the following file management tasks in Hadoop:
∙ Adding files and directories
∙ Retrieving files from HDFS to local filesystem
∙ Deleting Files from HDFS
Procedure:
Step 1: Adding Files and Directories to HDFS
: Before you can run Hadoop programs on data stored in HDFS, you’ll need to put the data into HDFS first. Let’s create a directory and put a file in it
hadoop fs -mkdir /user/myfile
hadoop fs -put a.txt
hadoop fs -put a.txt /user/myfile
Step 2: Retrieving Files from HDFS
The Hadoop command get copies files from HDFS back to the local filesystem. To retrieve a.txt, we can run the following command:
hadoop fs -cat a.txt
Step 3: Deleting Files from HDFS
hadoop fs -rm a.txt
Output:
