I can hardly script these days
I cobbled this together after several brief visits to tldp:
Code:
#!/bin/bash
#usage: ./script-name <file-name
#assuming count starts from Av102:
check=102
# read each line till eof:
while read line
do
#assuming Avxxx is the first column of each line:
test=$(echo $line | awk '{print $1}' | cut -c3-)
if [ $test != $check ]
then
echo "Error! $check is missing!"
break
fi
check=$(expr 1 + $check)
done
My file is called temp.sh and I made a temporary test file called temp.txt with these contents:
Code:
Av102 blah
Av103 blahblah
Av104 blah
Av106 blh
Av107 asdf
Av108 asdfasdf
When I run it, this is what I get in the output (note that I'm passing the contents of temp.txt, not just the filename, i.e
<temp.txt:
Code:
bash-2.05b ~/scrap$ ./test.sh <temp.txt
Error! 105 is missing!
bash-2.05b ~/scrap$
Now I'll wait for someone to post a perl one-liner that does the same thing..