- It's variables are untyped or (for practical purposes)  just one type - string.  In order to use numeric values stored as strings, there are some cryptic work-arounds.
 - 0=TRUE.  In every other programming language I've used, it's the opposite.  It reminds me of a scene from a movie called "The Gods Must Be Crazy" where in an African tribe, people nodded their heads to indicate "no" and shook their heads to mean "yes".  At least once a script I get tripped up by this.  I know it's because the Linux exit status for "job well done" is 0, but it's still a drag.
 
Here's a sample script I did for the lab:
#!/bin/bash
#
# lsname.bash # This script prints out the longest and shortest names in /etc/passwd
#
SNAME="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
LNAME=""
while IFS=: read USER PASS USERID GID GECOS HOME SHELL
do
if test ${#USER} -gt ${#LNAME}
then
LNAME=$USER
fi
if test ${#USER} -lt ${#SNAME}
then
SNAME=$USER
fi
done < /etc/passwd
echo "Longest name in /etc/passwd is $LNAME - ${#LNAME} characters"
echo "Shortest name in /etc/passwd is $SNAME - ${#SNAME} character"
---
Bash Resources
http://tldp.org/LDP/abs/html/
http://wooledge.org:8000/
http://www.tldp.org/HOWTO/
Btw, this post is not meant to be flame bait. I just needed to vent a little.
No comments:
Post a Comment