Skip to content

Instantly share code, notes, and snippets.

@lowstz
Created August 23, 2012 03:26
Show Gist options
  • Save lowstz/3431882 to your computer and use it in GitHub Desktop.
Save lowstz/3431882 to your computer and use it in GitHub Desktop.
简陋的作业统计
#!/bin/bash
# [usage]: homework_statistics.sh /path/to/your/student/homework/directory
#
mkdir -p ~/.homework_statistics
touch ~/.homework_statistics/result_list_$(date +%y-%m-%d-%H)
tmp_file=~/.homework_statistics/student_num_list
result_file=~/.homework_statistics/result_list_$(date +%y-%m-%d-%H)
full_file_path=$(cd $1; pwd)
cd ${full_file_path}
for rar_file in $(echo *.rar)
do unrar t $rar_file > /dev/null 2>&1
if [[ $? == 10 ]]; then
echo $rar_file | cut -c1-9 >> $tmp_file
done
for zip_file in $(echo *.zip)
do unzip -t zip_file > /dev/null 2>&1
if [[ $? == 9 ]]; then
echo $zip_file | cut -c1-9 >> $tmp_file
done
sort -h $tmp_file >> $result_file
rm -rf $tmp_file
less $result_file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment