Hint for the lazy programmer. How many times did you need to make switches/If clauses/… with lots of conditions, maybe coming from the n-th field of a each line in a file?
You’re lucky: bash and awk are here to help. This example generates (brrr…) VB code:
#!/bin/bash
while read line
do
echo "If variable = `echo $line | awk {'print $1;'}` Then " >> new_file
echo " boolean = True" >> new_file
echo "End If" >> new_file
echo " " >> new_file
done < file_to_read
Tags: bash awk
October 11, 2008 at 3:12 am
wonderful.. thanks for the tip