Skip to content

Instantly share code, notes, and snippets.

@vu3jej
Created August 4, 2016 08:05
Show Gist options
  • Save vu3jej/61bf096116e45e3e85be1fd78e6317d9 to your computer and use it in GitHub Desktop.
Save vu3jej/61bf096116e45e3e85be1fd78e6317d9 to your computer and use it in GitHub Desktop.
Print immediate parent directory along with filename and the file size
#!/bin/bash
for filename in $(find . -type f -print)
do
du_out=$(du -s $filename)
splitted=($(echo ${du_out}))
size="${splitted[0]}"
abs_path="${splitted[1]}"
parent_dir=$(basename $(dirname "$abs_path"))
filename=$(basename "$abs_path")
echo "${parent_dir},${filename},${size}"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment