How to remove full path in hadoop fs -ls and only list the file names in a hdfs directory along with other long listing

Viewed 9

Current out put :

hadoop fs -ls /user/avk/Test 
Found 2 items 
-rw-r--r-- 3 avk avk 6 2022-09-20 10:04 /user/avk/Test/test1.txt 
-rw-r--r-- 3 avk avk 6 2022-09-20 10:04 /user/avk/Test/test2.txt

I need a command which should list as above with permissions , owner, group , date , etc But I don't want the full path of file names. It should only list the file names inside that directory : /user/avk/Test Required output :

Found 2 items 
-rw-r--r-- 3 avk avk 6 2022-09-20 10:04 test1.txt 
-rw-r--r-- 3 avk avk 6 2022-09-20 10:04 test2.txt
1 Answers

There isn't any command for this. You'll need to write your own script to parse those lines and pipe the output of that command to it, for example, or rewrite the command itself, which is done in Java

Related