One-line batch file renamer
If you want to batch rename a bunch of files (say “foo*.jpg” to “bar*.jpg”), you might think you could just do “mv foo*.jpg bar*.jpg” in the Terminal. However, this doesn’t work right since the shell expands each argument before the execution occurs. However, there’s a cool way to accomplish the same result with a (more […]
Bash misc tips
Bash debugging A nice thing to do is to add on the first line #!/bin/bash -x This will produce some interesting output information Reading user input with read In many ocations you may want to prompt the user for some input, and there are several ways to achive this. This is one of those ways: […]
Bash user interfaces
Using select to make simple menus #!/bin/bash OPTIONS=”Hello Quit” select opt in $OPTIONS; do if [ “$opt” = “Quit” ]; then echo done exit elif [ “$opt” = “Hello” ]; then echo Hello World else clear echo bad option fi done If you run this script you’ll see that it is a programmer’s dream for […]