A File Fails to Be Queried or Deleted, and the File Can Be Viewed in the Parent Directory (Invisible Characters)
Symptom
A file fails to be queried or deleted using the HDFS Shell client. The file can be viewed in the parent directory.
Cause Analysis
The possible cause is that invisible characters are written to the file. You can write the file name to the local text and run the vi command to open the file.
hdfs dfs -ls parent directory > /tmp/t.txt
vi /tmp/t.txt
Run the :set list command to display invisible characters in the file name. For example, the file name contains ^M, which is invisible.
Solution
- Run the Shell command to read the file name recorded in the text. Ensure that the following command output contains the full path of the file in HDFS.
cat /tmp/t.txt |awk '{print $8}'
Figure 3 File path
- Run the following command to delete the file:
hdfs dfs -rm $(cat /tmp/t.txt |awk '{print $8}')
- Verify that the file has been deleted.
hdfs dfs -ls parent directory
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot