Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to edit txt file inside the HDFS in terminal?

Tags:

hadoop

hdfs

Is there any way to modify the txt file inside HDFS directly via terminal? Assume, I have "my_text_file.txt", and I would like to modify it inside HDFS using below command.

$ hdfs dfs -XXXX user/my_text_file.txt

I am interested to know "xxxx" if there exists any. Please note that I don't want to make modification in local and then copy it to HDFS.

like image 539
ARASH Avatar asked Oct 15 '25 14:10

ARASH


2 Answers

You cannot edit files, which all are already in HDFS. It will not support. HDFS works on "Write once, read many". So if you want to edit a file, make changes in your local copy then move it to HDFS.

like image 113
BruceWayne Avatar answered Oct 18 '25 10:10

BruceWayne


Currently as explained by @BruceWayne, its not possible. It would be very difficult to edit the files stored in hdfs because all the files are distributed in hdfs and it would be very difficult to edit in the terminal using hdfs commands. Currently these are supported as terminal commands.

You can edit them by locating the data location of each datanode in the cluster.But that would be troublesome.

Moreover you can install HUE. With HUE you can edit the files in hdfs using web UI.

like image 21
Ramesh Maharjan Avatar answered Oct 18 '25 11:10

Ramesh Maharjan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!