Tag: bash
We can compute the Greatest Common Divisor (GCD) using Iterative Divide/Remainder Method. The following is the GCD implementation in BASH Programming: #!/bin/bash function gcd() { local x=$1 local y=$2 …
On Linux, we can cat the file “/proc/meminfo” to display memory related information: $ cat /proc/memoinfo MemTotal: 32939372 kB MemFree: 31155452 kB MemAvailable: 31269760 kB Buffers: 242964 kB Cached: …
sudo is the command to allow normal users perform some escalated operations. We can use the following BASH function to check to see if the sudo command is available. …
We can use the following BASH function escape to escape the parameter strings and put them one by one. For example: #!/bin/bash function escape () { for i do …
The inbuilt BASH does not support floating point arithmetic calculations but we can easily declare a function to do so via AWK. #!/bin/bash # calc.sh function calc() { awk …