devops-exercises/topics/shell/solutions/files_size.md
abregman 99c4e02ecf Rename exercises dir
Name it instead "topics" so it won't be
strange if some topics included "exercises" directory.
2022-08-02 01:53:56 +03:00

247 B

Files Size

Objectives

  1. Print the name and size of every file and directory in current path

Note: use at least one for loop!

Solution

#!/usr/bin/env bash

for i in $(ls -S1); do
    echo $i: $(du -sh "$i" | cut -f1)
done