Sunday, November 29, 2015

Adding a list of numbers in linux command line

Lets say, that you want to see how much space a specific set of files take in the disk. You need to add their sizes. How do you do that using command line?
Easy: ls -l *052015|awk '{s+=$5}END { print s}'

This will sum the size of backups made in May 2015 and return the total. Neat eh?

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.