I use Bash (the bourne
again shell). This is another page where I will keep things that I regularly
forget about shell scripts in general (not just bash).
Here are two recent scripts I wrote recently that include a lot of the things that I tend to forget:
#!/bin/bash if [ $# -lt 2 ] ; then PN=`basename "$0"` echo >&2 "usage: $PN" exit 1 fi echo "HELLO STUFF $1 $2"
#!/bin/bash
F=0.5879500E9
STEP=0.01
for((i=9; i<=18; i++)) ; do
INPUT=`printf "fort.%d" $i`
OUTPUT=`printf "out%d" $i`
echo -e "$INPUT --process--> $OUTPUT \c"
rm $OUTPUT
A=0.0
while [[ `echo "$A < 0.5" | bc` -ne 0 ]] ; do
OA=`printf "%4.2f" $A`
echo -e "\b\b\b\b$OA\c"
B1=`echo $A | cat - $INPUT | ./alibaba-5`
B2=`echo $B1 | awk '{ print ($4 + $5) }'`
B3=`echo $B1 | awk '{ print $7, $8 }'`
B=`echo $B2 * $F | bc`
echo "$OA $B $B3" >> $OUTPUT
A=`echo $A + $STEP | bc`
done
echo -e "\b\b\b\bDONE"
done