Tag: Shell Programming
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 …
June 23, 2021
algorithms, BASH, bash script, Combination, math, Permutation, programming languages, Recursion, recursive, string
Swap Two Characters in BASH In BASH, we can use “${#string}” to get the length of a string. And in a function, we use “local” keyword to declare local …