Hands-on task
Find the maximum in a file
/root/nums.txt contains integers, one per line (some may be negative). Write /root/max.sh that finds the largest one and prints it. Run it, with the result going into /root/max.txt.
- while read loop
- reading a file line by line
- comparing numbers -gt
- variable initialization
- finding the maximum