The input file:
Code:
$ cat ttt
ID .... VALUE
-------------
A001 .... 100
C003 .... 800
B002 .... 200
corrupt
data
A004 .... 300
C003 .... 800
foo .... bar
The script:
Code:
#!/bin/ksh
INPUT=ttt
{ while read LINE
do
echo $LINE |egrep "^A|^B" > /dev/null 2>&1
if [ $? -eq 0 ]
then
echo "Processing $LINE"
else
echo "Skipping $LINE"
fi
done } < $INPUT
The output:
Code:
$ ./ttt.ksh
Skipping ID .... VALUE
Skipping -------------
Processing A001 .... 100
Skipping C003 .... 800
Processing B002 .... 200
Skipping corrupt
Skipping data
Processing A004 .... 300
Skipping C003 .... 800
Skipping foo .... bar
You could do a single string of commands using awk for the pattern matching, but I'm not sure how you want to process the line once you verify it's good... so this may offer the most flexibility.
Let us know if you need anything in the script explained.