Advertisement
Guest User

Untitled

a guest
Feb 15th, 2013
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.10 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. file="$1"
  4. file1='/tmp/tmp_quotations_extract1'
  5. # Только цитаты
  6. file2='/tmp/tmp_quotations_extract2'
  7. seps='\$\$'
  8.  
  9. command=`basename "$0"`
  10.  
  11. useparam ()
  12. {
  13.     if [ "$1" = '--help' ] || [ "$1" = "" ]; then
  14.             echo -e "[$command]: Использование параметров:\n1: Файл для чтения" && exit
  15.         fi
  16. }
  17.  
  18. exist ()
  19. {
  20.         if [ ! -e "$1" ]; then
  21.                 echo "[$command]: Объект [$1] не найден."
  22.                 exit
  23.         fi
  24. }
  25.  
  26. remove_tmp ()
  27. {
  28.         rm "$file1" "$file2"
  29. }
  30.  
  31. useparam "$file"
  32. exist "$file"
  33. exist "$file2"
  34.  
  35. echo "[$command]: Объединение цитат с переводом..."
  36.  
  37. let i=0
  38. while read line; do
  39.     array[$i]="$line"
  40.     let i=$i+1
  41. done < "$file2"
  42.  
  43. maxi=${#array[@]}
  44. #echo "Debug: maxi: [$maxi]"
  45.  
  46. par=""
  47. let i=0
  48. while [ "$i" -lt "$maxi" ]; do
  49.     line="${array[$i]}"
  50.     #sed -i "s/$seps/\[\[$line\]\]/" "$file"
  51.     echo "[$i]: Заменяю [$seps] на [$line]..."
  52.     #echo "Debug: i: [$i]"
  53.     #echo "Debug: a[i]: [$line]"
  54.     let i=$i+1
  55.     #mo "$file"
  56. done
  57.  
  58. #remove_tmp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement