0 votes
1 view
in Big Data Hadoop & Spark by (11.5k points)

I would like to know is there any command/expression to get only the file name in hadoop. I need to fetch only the name of file, when I do hadoop fs -ls it prints the whole path.

I tried below but just wondering if some better way to do it.

hadoop fs -ls <HDFS_DIR>|cut -d ' ' -f17

1 Answer

0 votes
by (31.4k points)
edited by

Try the command below and get the file names only:

$ hdfs dfs -ls /user | awk -F'/' '{print $NF}'

image

For more information regarding Hadoop, refer to the following video tutorial:

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...