Permalink
Browse files

refactor script

  • Loading branch information...
1 parent aa8d6df commit f8d02c280e568ac76c96fbca983aae8d77b08185 @takeshe12 committed Jan 28, 2017
Showing with 17 additions and 13 deletions.
  1. +17 −13 getfile.sh
View
@@ -1,21 +1,25 @@
#!/bin/bash #!/bin/bash
# check file exists # check file exists
-if [ -e info/infolist ]; then +for file in infolist infoalllist
- rm info/infolist +do
-fi + if [ -e info/$file ]; then
-if [ -e info/infoalllist ]; then + rm info/$file
- rm info/infoalllist + fi
-fi +done
# get early 3 files # get early 3 files
-files=`ls info | sort -r | head -n 3`
allfiles=`ls info | sort -r` allfiles=`ls info | sort -r`
-# except extention(.html) +for file in infolist infoalllist
-for filepath in $files; do +do
- basename $filepath .html >> info/infolist + i=0
-done + for filepath in $allfiles; do
-for filepath in $allfiles; do + if [ $file = "infolist" ] && [ $i -eq 3 ]; then
- basename $filepath .html >> info/infoalllist + break
+ fi
+ # except extention(.html)
+ basename $filepath .html >> info/$file
+ i=$(( i + 1 ))
+ done
done done

0 comments on commit f8d02c2

Please sign in to comment.