Skip to content

Commit

Permalink
Use awk instead of sed when parsing du output (#112)
Browse files Browse the repository at this point in the history
This feel a little less "magic", is better readable and maintainable. Might have a slight impact on performance, too.
  • Loading branch information
chr4 committed May 8, 2024
1 parent ab04a51 commit 251b8a7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion directory-size.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
echo "# HELP node_directory_size_bytes Disk space used by some directories"
echo "# TYPE node_directory_size_bytes gauge"
du --block-size=1 --summarize "$@" \
| sed -ne 's/\\/\\\\/;s/"/\\"/g;s/^\([0-9]\+\)\t\(.*\)$/node_directory_size_bytes{directory="\2"} \1/p'
| awk '{ print "node_directory_size_bytes{directory=\"" $2 "\"} " $1 }'

0 comments on commit 251b8a7

Please sign in to comment.