|
Programming HowTo's -
Shell HowTo's
|
|
Written by Christopher Hahn
|
|
Sunday, 04 May 2008 18:55 |
|
BASH
We've all heard of shell programming, but in the end what we write are simple scripts composed of strung-together commands, performing simple operations in a more-or-less linear manner. But the shell can do much more than what we tend to ask of it.
bash is, in my opinion, the most powerful shell on the market that doesn't require you to be a programmer to use it. On the other hand, for those who want to learn to program it, rather than just script it, its sound principles and powerful features offer a wealth of opportunity for writing fast, flexible programs that can often out-perform most other interpreted languages.
This is a very informal crash tutorial in intermediate features of shell programming. It assumes a basic grasp of programming principles and of simple, beginner-level shell scripting.
|
|
Last Updated on Sunday, 18 May 2008 07:45 |
|
Read more...
|
|
Programming HowTo's -
Shell HowTo's
|
|
Written by Christopher Hahn
|
|
Monday, 28 April 2008 11:09 |
|
#!/bin/bash # Generate unique valid XEN MAC addresses in shell, 'cause it's faster ;) # Xen MAC's begin with 00:16:3e
declare -i num="${1:-0}" until [[ $num -gt 0 ]]; do read -p "How many MAC's do you want to generate? " num done
declare -a macs=( )
while [[ $num -gt 0 ]]; do mac=$(printf '%02x:%02x:%02x' $((RANDOM % 256)) $((RANDOM % 256)) $((RANDOM % 256)))
for i in "${macs[@]}"; do [[ $mac = $i ]] && continue 2 done
macs[${#macs[*]}]=$mac echo 00:16:3e:$mac num=$((num-1)) done
|
|
Last Updated on Monday, 28 April 2008 20:45 |
|
Programming HowTo's -
Shell HowTo's
|
|
Written by Christopher Hahn
|
|
Monday, 28 April 2008 08:32 |
|
#!/bin/bash # Execute commands locally or remotely based on fields in records.
# Only supports single-character record separators, but field delimiters may be # many characters (and that's probably a good idea).
# Author: Christopher Hahn, Apr 2008
|
|
Last Updated on Sunday, 25 May 2008 00:11 |
|
Read more...
|