Skip to content

Instantly share code, notes, and snippets.

@mamiu
Last active August 29, 2015 14:06
Show Gist options
  • Select an option

  • Save mamiu/e305e3bc31999f79ff98 to your computer and use it in GitHub Desktop.

Select an option

Save mamiu/e305e3bc31999f79ff98 to your computer and use it in GitHub Desktop.
#!/bin/bash
find . -type f -name '*' -print0 | while IFS= read -r -d '' file
do
name=$(basename "$file")
path=$(dirname "$file")
full_path=$(readlink -f "$file")
extension=${name##*.}
size_in_bytes=$(stat -c%s "$file")
size_human_readable=$(ls -lh "$file" | awk -F' ' '{print $5}')
creation_date=$(stat -c%w "$file" | cut -c -19)
last_access=$(stat -c%x "$file" | cut -c -19)
last_modification=$(stat -c%y "$file" | cut -c -19)
last_change=$(stat -c%z "$file" | cut -c -19)
printf "[$file]:\n"
printf "\tfile name:\t\t$name\n"
printf "\tfile path:\t\t$path\n"
printf "\tfull file path:\t\t$full_path\n"
printf "\tfile extension:\t\t$extension\n"
printf "\tfile size:\t\t$size_human_readable\n"
printf "\tfile size in bytes:\t$size_in_bytes\n"
[ "$creation_date" != "-" ] && printf "\tfile creation date:\t\t$creation_date\n"
[ "$last_access" != "-" ] && printf "\tlast file access:\t$last_access\n"
[ "$last_modification" != "-" ] && printf "\tlast file modification:\t$last_modification\n"
[ "$last_change" != "-" ] && printf "\tlast file change:\t$last_change\n"
printf "\n"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment