Get a few lines of HDFS data

前端 未结 9 1842
一整个雨季
一整个雨季 2021-02-04 02:17

I am having a 2 GB data in my HDFS.

Is it possible to get that data randomly. Like we do in the Unix command line

cat iris2.cs         


        
相关标签:
9条回答
  • 2021-02-04 03:13
    hadoop fs -cat  /user/hive/warehouse/vamshi_customers/* |tail
    

    I think the head part is working as per the answer posted by @Viacheslav Rodionov works fine but for the tail part the one that I posted is working good.

    0 讨论(0)
  • 2021-02-04 03:14

    You can use head command in Hadoop too! Syntax would be

    hdfs dfs -cat <hdfs_filename> | head -n 3
    

    This will print only three lines from the file.

    0 讨论(0)
  • 2021-02-04 03:14

    Write this command

    sudo -u hdfs hdfs dfs -cat "path of csv file" |head -n 50
    

    50 is number of lines(this can be customize by the user based on the requirements)

    0 讨论(0)
提交回复
热议问题