Advertisement
Tragique

scroller.sh

May 6th, 2021
934
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.83 KB | None | 0 0
  1. #!/bin/bash
  2. # if you need to scroll back to a certain fine combination _item maybe
  3.  
  4. clear;
  5.  
  6. if (( $# != 6 )); then
  7. echo "
  8. scroller.sh is used to scroll throughout a file ...
  9.  
  10. usage: mode         direction "up" or "down"        _string
  11.        start        starting character      _int        ( relative to mode )
  12.        size         page size           _int
  13.        step         characters step size        _int
  14.        interval     sleep interval          _int
  15.        file     targeted file           _string
  16. "
  17. read x;
  18. exit;
  19. fi
  20.  
  21. mode=$1;
  22. start=$2;
  23. size=$3;
  24. step=$4;
  25. sinterval=$5;
  26. file=$6;
  27.  
  28.  
  29.  
  30. index=$(( $size + $start ));
  31.  
  32. while true;
  33.  
  34. do
  35.  
  36. if (( $mode == "down" )); then
  37.  
  38. cat $file | head -c $index | tail -c $size;
  39.  
  40.  
  41. fi
  42. if (( $mode == "up" )); then
  43.  
  44. cat $file | tail -c $index | head -c $size;
  45.  
  46.  
  47. fi
  48.  
  49. index=$(( "$index" + "$step" ));
  50.  
  51. sleep $sinterval;
  52. clear;
  53.  
  54. done
  55.  
  56. #
  57.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement