document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. #!/bin/bash
  2. #給emacs用,可計算中英文夾雜的文件字數,並忽略在org-mode裡的*#等符號
  3. function start_count {
  4.         n1=`echo "$data_in_buffer" | sed \'s/[a-zA-Z][a-zA-Z]*//g\' | sed \'s/\\*//g\' \\
  5.             | sed -e \'s/[,。:;!?「」『』#,.:;?!《》]//g\' -e \'s/[()]//g\' -e \'s/[\\[\\]]//g\' -e \'s/[ \\t]//g\' \\
  6.             | awk \'BEGIN{n=0}{n+=length($0)}END{print n}\'`
  7.  
  8.         n2=`echo "$data_in_buffer" | grep -o \'[a-zA-Z][a-zA-Z]*\' | wc -w`
  9.        
  10.         total=`expr $total + $n1 + $n2`
  11.  
  12. }
  13.  
  14. total=0
  15.  
  16. while read data_in_buffer; do
  17.     start_count
  18. done
  19.  
  20. echo "Total: ${total} words (not include puctuation)"
');