Answered step by step
Verified Expert Solution
Question
1 Approved Answer
4 units.sh Write a Bash script named units.sh, that takes a single command-line argument, which is a number of bytes. The script should then display
4 units.sh Write a Bash script named units.sh, that takes a single command-line argument, which is a number of bytes. The script should then display the (roughly) equivalent number of bytes using both the base ten, and the binary, SI prefixes. If the number of bytes is less than 1,000 , then the script should simply display the number of bytes. If the number of bytes is at least 1,000 , then both the base ten and binary outputs should have the format Www.fff units where www is at most 3 digits and represents the whole portion, fff is exactly 3 digits and represents the fractional portion, and units are the appropriate units. 4.1 Error handling An appropriate error message should be displayed if the script is invoked without exactly one command-line argument. If one argument is given, the script may assume that it is a number between 0 and 10151. 4.2 Examples The following examples serve to illustrate the expected behavior of the script for various inputs. user $ units.sh Usage: units.sh \#bytes user $ units.sh 42 42 bytes 42 bytes user $ units.sh 1003 1.003 kbytes 0.979 Kibytes user $ units.sh 65536 65.536 kbytes 64.000 Kibytes user $ units.sh 123456 123.456 kbytes 120.562 Kibytes user $ units.sh 1234567 1.234 Mbytes 1.176 Mibytes user $ units.sh 1020304050 1.020 Gbytes 973.037 Mibytes user $ units.sh 10203040506070 10.203 Tbytes 9.279 Tibytes user $ units.sh 908070605040302 908.070 Tbytes 825.884 Tibytes user $ 4 units.sh Write a Bash script named units.sh, that takes a single command-line argument, which is a number of bytes. The script should then display the (roughly) equivalent number of bytes using both the base ten, and the binary, SI prefixes. If the number of bytes is less than 1,000 , then the script should simply display the number of bytes. If the number of bytes is at least 1,000 , then both the base ten and binary outputs should have the format Www.fff units where www is at most 3 digits and represents the whole portion, fff is exactly 3 digits and represents the fractional portion, and units are the appropriate units. 4.1 Error handling An appropriate error message should be displayed if the script is invoked without exactly one command-line argument. If one argument is given, the script may assume that it is a number between 0 and 10151. 4.2 Examples The following examples serve to illustrate the expected behavior of the script for various inputs. user $ units.sh Usage: units.sh \#bytes user $ units.sh 42 42 bytes 42 bytes user $ units.sh 1003 1.003 kbytes 0.979 Kibytes user $ units.sh 65536 65.536 kbytes 64.000 Kibytes user $ units.sh 123456 123.456 kbytes 120.562 Kibytes user $ units.sh 1234567 1.234 Mbytes 1.176 Mibytes user $ units.sh 1020304050 1.020 Gbytes 973.037 Mibytes user $ units.sh 10203040506070 10.203 Tbytes 9.279 Tibytes user $ units.sh 908070605040302 908.070 Tbytes 825.884 Tibytes user $
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started