Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to print file tree with hadoop?

I'm a new bird in HDFS and *nix, and I'm just curious, how to print a file tree in hadoop?

for example, we can type "tree" in any *nix system, and give us a result like that:

[admin~]$tree
.
├── backup_snapshot.sh
├── project
│   ├── doc
│   │   └── README
│   ├── src
....

that is very clearly output, but since the HDFS is not fully POSIX compliant, so I'm not sure how to print that in hadoop.

like image 740
mark Avatar asked Jan 25 '13 04:01

mark


1 Answers

Based on http://en.wikipedia.org/wiki/Tree_(Unix) you can come up with a tree like representation, e.g:

hadoop fs -lsr /mydir | awk '{print $8}' | \
sed -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/'
like image 129
Lorand Bendig Avatar answered Sep 28 '22 03:09

Lorand Bendig