Moreover, what happened if we delete any file from HDFS?
Actually any file stored in hdfs is split in blocks (chunks of data) and each block is replicated 3 times by default. When you delete a file you remove the metadata pointing to the blocks that is stored in Namenode. Blocks are deleted when there is no reference to them in the Namenode metadata.
Similarly, how do I delete old files in HDFS? Delete files older than 10days on HDFS
- There is no find command, but hdfs dfs -ls -R /path/to/directory | egrep .
- @cricket_007 but how do we do the older than 'x' days?
- You'd have to cut out the date portion of the standard output, store that filtered file list, and run hdfs dfs -rm in a loop
- I use this script.
Then, when a file in HDFS is deleted by a user?
When you delete a file in HDFS, the file is not immediately expelled from HDFS. Deleted files are first moved to the /user/<username>/.Trash/Current directory, with their original filesystem path being preserved. After a user-configurable period of time ( fs.
How do I edit an HDFS file?
Get the original file from HDFS to the local filesystem, modify it and then put it back on HDFS.
- hdfs dfs -get /user/hduser/myfile.txt.
- vi myfile.txt #or use any other tool and modify it.
- hdfs dfs -put -f myfile.txt /user/hduser/myfile.txt.