Hadoop fs -stat command

0 votes
What does hadoop fs -stat command do?
Jun 13, 2018 in Big Data Hadoop by shams
• 3,670 points
13,754 views

2 answers to this question.

0 votes
Best answer

hadoop fs -stat is as hadoop command used to check the stats of a particular file in the hadoop file system. Suppose I have a folder named Hadoop-folder in the hdfs, then to check the stats of this folder, i would run the command:

hadoop fs -stat /Hadoop-folder

By default, this command returns the date and time when the folder was last updated

The syntax for this command is 

hadoop fs -stat [format] <path>
answered Oct 25, 2018 by Omkar
• 69,180 points

selected Oct 25, 2018 by Omkar

You said "by default", are there other ways to use this? And in the syntax, I am guessing <path> is the path to the file but what is [format]?

Hey there!

Yes, there are other "options" you can use with this command. 

Yes,

 <path> is the path to the file

[format] is used to specify other options. To find out other options, you can run the command:

hadoop fs -help stat

Output:

Usage: hadoop fs -stat [format] <path> ...

Print statistics about the file/directory at <path> in the specified format. 
Format accepts permissions in octal (%a) and symbolic (%A), 
filesize in bytes (%b), type (%F), group name of owner (%g), 
name (%n), block size (%o), replication (%r), 
user name of owner(%u), access date(%x, %X), 
and modification date (%y, %Y). %x and %y show UTC date as “yyyy-MM-dd HH:mm:ss”, 
and %X and %Y show milliseconds since January 1, 1970 UTC. 
If the format is not specified, %y is used by default.
I want to get stats related to more than one options. Right now what I am doing is running the command again and again with different options. Is there a short-cut for this?

Hi. Suppose you want to get more than one stat, you can use multiple options in a single command. For example if you want to get details about file size in bytes (%b) and block size (%o), then the command would be 

hadoop fs -stat %b%o <path>