Advertisement
cd62131

Print Maximums

Dec 21st, 2017
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.43 KB | None | 0 0
  1. #!/bin/bash
  2. max_x=
  3. max_y=
  4. while IFS= read -r line; do
  5.   if [[ -z ${line} ]]; then
  6.     printf '%s %s\n\n' ${max_x} ${max_y}
  7.     max_x=
  8.     max_y=
  9.     continue
  10.   fi
  11.   read -r x y <<<${line}
  12.   if [[ -z ${max_y} ]]; then
  13.     max_x=${x}
  14.     max_y=${y}
  15.     continue
  16.   fi
  17.   if (( $(bc -l <<<"${y}>${max_y}") )); then
  18.     max_x=${x}
  19.     max_y=${y}
  20.   fi
  21. done
  22. if [[ ! -z ${max_y} ]]; then
  23.   printf '%s %s\n' ${max_x} ${max_y}
  24. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement