Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

  #!/usr/bin/env bash
  
  WANTMODE=wal
  
  for file in "$@"; do
      MODE=`sqlite3 -init <(echo .timeout 10000) -batch "$file" 'PRAGMA journal_mode;'`
      if [[ $MODE == $WANTMODE ]]; then continue; fi
      OLDSIZE=`du -kc "$file" "$file-wal" "$file-shm" 2>/dev/null | tail -n1 | cut -f1`
      echo -n "$file: "
      echo "PRAGMA journal_mode=$WANTMODE;" | sqlite3 -init <(echo .timeout 10000) -batch "$file"
      if [[ $? != 0 ]]; then continue; fi
      NEWSIZE=`du -kc "$file" "$file-wal" "$file-shm" 2>/dev/null | tail -n1 | cut -f1`
      echo "${OLDSIZE}kb -> ${NEWSIZE}kb"
  done


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: