Advertisement
Guest User

testcycle (1)

a guest
Jul 13th, 2012
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.62 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. file="/tmp/info"
  4. tmpfile="/tmp/tmp_tst"
  5.  
  6. replace ()
  7. {
  8.     replace_what="$1"
  9.     replace_with="$2"
  10.     sed -i "s/$replace_what/$replace_with/g" "$tmpfile"
  11. }
  12.  
  13. replace_all ()
  14. {
  15.     replace "плотину" "the dam"
  16.     replace "фотографий" "photos"
  17.     replace "оказалось" "it has appeared that"
  18.     replace "наводнение" "the flood"
  19.     replace "В итоге" "As a result,"
  20. }
  21.  
  22. test_cycle ()
  23. {
  24.     echo "Прогон цикла замены..."
  25.     let i=0
  26.     while [ $i -le "500" ]; do
  27.         replace_all
  28.         ((i++))
  29.     done
  30.     echo "Завершено."
  31. }
  32.  
  33. cat "$file" > "$tmpfile"
  34. time test_cycle
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement