You don’t need calculators or other languages and compilers to do math. You can do a lot in bash (GNU Bourne-Again SHell), and it’s really easy!
Since you can’t really pass pointers or references to arrays and you can’t return anything other than integers, here’s how to implement push, pop, shift, and unshift in a bash shell script. I don’t know if this already exists in bash, but I couldn’t find it and I needed a data structure in a hurry.
Shopt toggles the values of variables controlling optional shell behavior. If you want to match a regular expression while ignoring the case, the easiest method is to use shopt. You can use shopt set, unset, and print out settable options such as the ability to expand aliases and debugging options.
Change lowercase to uppercase or vice versa using sed the brute force easy way and the smart way. One use of this would be finding the hardware address of an interface and converting it to all uppercase.
This one should be pretty bulletproof. Use a single sed command to dump the list of all ip addresses from interfaces showing in ifconfig.
99% of the time you can just use the local address to talk to yourself. This is just an example to show you how wrangle the ip address using awk. Rewrite the hosts file so the host itself can use it’s external address by name. Write out the basic stuff in hosts that doesn’t change then write out the current IP address.
What would I do without the Linux shell? The sheer number of mouse clicks required to do this in Windows would result in instant and painful arthritis. For each Makefile in any child directory below pwd, It’s looking for a broken include string where the include was specified after the library and if it finds this case, it rewrites that part so it’s include/library. It’s basically the same thing done over and over for each include that might exist in any Makefile.
Here’s a short bash script to parallelize your jobs. There are utilities already written for just this type of thing, but forget xargs. Check out xjobs instead.
You have a bunch of related applications, each has their own Makefile that knows only about their own application, but you have dependencies where one app needs to be built before another. Here’s a skeleton bash script for building any one thing or everything.
#!/bin/bash
function build {
echo "*** …
This is so handy, I can’t believe i’ve never used or even heard of this until today! You can easily run your bash shell scripts in debug mode to watch what they’re doing behind the scenes in real time. You get to see the levels of nesting when you’re inside loops and variables get replaced with their actual contents at the time of execution.
This might come in handy if you have multiple levels of nesting in ‘for’ and ‘while’ loops or a few if/then/else statements and you want to see just what is getting passed in the comparisons.