jacobstanley / hadoop-tools

Tools for working with Hadoop, written with performance in mind.
Other
37 stars 15 forks source link

Using boxes makes output hard to grep #20

Open thsutton opened 7 years ago

thsutton commented 7 years ago

Using boxes for du hh output makes it hard to grep the output due to the right padding.

Here's a contrived shell session.

$ hh du /some/directory
1G /some/directory/ABC/
1G /some/directory/A/
1G /some/directory/B/
1G /some/directory/C/
$ hh du /some/directory | egrep '/[A-Z]/$'
$ hh du /some/directory | hexdump -C
00000000  31 47 20 2f 73 6f 6d 65  2f 64 69 72 65 63 74 6f  |1G /some/directo|
00000010  72 79 2f 43 2f 20 20 0a                           |ry/C/  .|
$ hh du /some/directory | egrep '/[A-Z]/ *$'
1G /some/directory/A/
1G /some/directory/B/
1G /some/directory/C/
$
jacobstanley commented 7 years ago

@thsutton maybe it's enough for us to just trim the whitespace of the end of each line?

thsutton commented 7 years ago

Yeah, should be. Something like

s/printBox/unlines . fmap (dropWhileEnd (`elem` " \t")) . lines . render/