Mercurial > ec-dotfiles
comparison moefetch.sh @ 235:649b7d4b056a
Use "grep -c ." instead of "echo $(wc -l <" evilry. I should stop trying to fix this script.
author | Edho Prima Arief <me@myconan.net> |
---|---|
date | Thu, 05 Aug 2010 15:27:07 +0700 |
parents | 58ad057cd2ec |
children |
comparison
equal
deleted
inserted
replaced
234:58ad057cd2ec | 235:649b7d4b056a |
---|---|
127 <xsl:template match="post"> | 127 <xsl:template match="post"> |
128 <xsl:value-of select="@file_url" /> | 128 <xsl:value-of select="@file_url" /> |
129 </xsl:template> | 129 </xsl:template> |
130 </xsl:stylesheet> | 130 </xsl:stylesheet> |
131 EOF | 131 EOF |
132 tempnum=$(echo $(wc -l < "${TEMP_PREFIX}-templist")) | 132 tempnum=$(grep -c . "${TEMP_PREFIX}-templist") |
133 iternum=$((iternum + 1)) | 133 iternum=$((iternum + 1)) |
134 cat "${TEMP_PREFIX}-templist" >> "${TEMP_PREFIX}-list" | 134 cat "${TEMP_PREFIX}-templist" >> "${TEMP_PREFIX}-list" |
135 echo "${tempnum} file(s) available" | 135 echo "${tempnum} file(s) available" |
136 done | 136 done |
137 numfiles=$(echo $(wc -l < "${TEMP_PREFIX}-list")) | 137 numfiles=$(grep -c . "${TEMP_PREFIX}-list") |
138 echo "${numfiles} file(s) available on server" | 138 echo "${numfiles} file(s) available on server" |
139 [ "${numfiles}" -gt 0 ] || Err_Fatal "Error in processing list or no files can be found with specified tag(s) or site." | 139 [ "${numfiles}" -gt 0 ] || Err_Fatal "Error in processing list or no files can be found with specified tag(s) or site." |
140 } | 140 } |
141 | 141 |
142 | 142 |
266 if [ ! -n "${has_err_md5}" ] && [ ! -n "${has_err_filename}" ]; then | 266 if [ ! -n "${has_err_md5}" ] && [ ! -n "${has_err_filename}" ]; then |
267 echo "All files OK" | 267 echo "All files OK" |
268 else | 268 else |
269 if [ -n "${has_err_md5}" ]; then | 269 if [ -n "${has_err_md5}" ]; then |
270 echo "${files_error}" | 270 echo "${files_error}" |
271 echo "$(echo $(wc -l < "${TEMP_PREFIX}-error")) file(s) removed" | 271 echo "$(grep -c . "${TEMP_PREFIX}-error") file(s) removed" |
272 fi | 272 fi |
273 [ -n "${has_err_filename}" ] && echo "${files_notdanbooru}" | 273 [ -n "${has_err_filename}" ] && echo "${files_notdanbooru}" |
274 fi | 274 fi |
275 echo "$(echo $(wc -l < "${TEMP_PREFIX}-ok")) file(s) available locally" | 275 echo "$(grep -c . "${TEMP_PREFIX}-ok") file(s) available locally" |
276 | 276 |
277 printf "Generating list of new files... " | 277 printf "Generating list of new files... " |
278 progress_init | 278 progress_init |
279 cp -f "${TEMP_PREFIX}-list" "${TEMP_PREFIX}-templist" | 279 cp -f "${TEMP_PREFIX}-list" "${TEMP_PREFIX}-templist" |
280 while read -r is_ok; do | 280 while read -r is_ok; do |
281 grep -v "${is_ok}" "${TEMP_PREFIX}-templist" > "${TEMP_PREFIX}-newlist" | 281 grep -v "${is_ok}" "${TEMP_PREFIX}-templist" > "${TEMP_PREFIX}-newlist" |
282 cp -f "${TEMP_PREFIX}-newlist" "${TEMP_PREFIX}-templist" || Err_Impossible | 282 cp -f "${TEMP_PREFIX}-newlist" "${TEMP_PREFIX}-templist" || Err_Impossible |
283 progress_anim | 283 progress_anim |
284 done < "${TEMP_PREFIX}-ok" | 284 done < "${TEMP_PREFIX}-ok" |
285 progress_done | 285 progress_done |
286 echo "$(echo $(wc -l < "${TEMP_PREFIX}-newlist")) file(s) to be downloaded" | 286 echo "$(grep -c . "${TEMP_PREFIX}-newlist") file(s) to be downloaded" |
287 else | 287 else |
288 if [ -n "${ISQUICK}" ]; then | 288 if [ -n "${ISQUICK}" ]; then |
289 echo "Quick mode selected. Skipping check" | 289 echo "Quick mode selected. Skipping check" |
290 else | 290 else |
291 echo "Empty local repository" | 291 echo "Empty local repository" |
294 fi | 294 fi |
295 } | 295 } |
296 | 296 |
297 # start downloading the images | 297 # start downloading the images |
298 Fetch_Images() { | 298 Fetch_Images() { |
299 if [ "$(echo $(wc -l < "${TEMP_PREFIX}-newlist"))" -eq 0 ]; then | 299 if [ "$(grep -c . "${TEMP_PREFIX}-newlist")" -eq 0 ]; then |
300 echo "No new file" | 300 echo "No new file" |
301 else | 301 else |
302 printf "Downloading files... " | 302 printf "Downloading files... " |
303 cd "${BASE_DIR}/${SITE_DIR}/${TARGET_DIR}" | 303 cd "${BASE_DIR}/${SITE_DIR}/${TARGET_DIR}" |
304 wget -e continue=on -i "${TEMP_PREFIX}-newlist" -o "${TEMP_PREFIX}.log" | 304 wget -e continue=on -i "${TEMP_PREFIX}-newlist" -o "${TEMP_PREFIX}.log" |