#!/bin/bash
readonly OBJECT_DIR="/Users/tanakahda/Desktop/test/*"
echo "
╭━━━┳━━━┳━━━┳━━━┳━╮╭━┳━━━╮ ╭╮╱╭╮╭╮╱╭╮
┃╭━╮┃╭━━┫╭━╮┣╮╭╮┃┃╰╯┃┃╭━━╯ ┃┃╱┃┣╯╰╮┃┃
┃╰━╯┃╰━━┫┃╱┃┃┃┃┃┃╭╮╭╮┃╰━━╮ ┃┃╱┃┣╮╭╋┫┃╭━━╮
┃╭╮╭┫╭━━┫╰━╯┃┃┃┃┃┃┃┃┃┃╭━━╯ ┃┃╱┃┃┃┃┣┫┃┃━━┫
┃┃┃╰┫╰━━┫╭━╮┣╯╰╯┃┃┃┃┃┃╰━━╮ ┃╰━╯┃┃╰┫┃╰╋━━┃
╰╯╰━┻━━━┻╯╱╰┻━━━┻╯╰╯╰┻━━━╯ ╰━━━╯╰━┻┻━┻━━╯
"
echo "
Please select a command no.
[?] Output the README of all students to one file: 1
[?] Do echo students who have not submitted a README: 2
"
exec_merge_file () {
output=ALL_README-`date "+%Y%m%d%H%M%S"`.log
for file in $(find . -type f -name 'README'); do
echo "-----------------------------" >> $output
ls -ltr $file >> $output
cat "$file" >> $output
done
}
exec_exists_file () {
directories=()
for object in $OBJECT_DIR; do
if [ -d $object ] ; then
directories+=("$object")
fi
done
for home_dir in ${directories[@]}; do
if [ ! -f "${home_dir}/README" ]; then
echo $home_dir
fi
done
}
read command_no
case $command_no in
"1")
exec_merge_file
;;
"2")
exec_exists_file
;;
*)
echo "Please select a exist number.";;
esac