nawk problem

How are ya,

Heres the problem.

I have a line of data that can either be in this format.

"20" or
"20kg"

for the 20kg one i need to be able to read that their is kg on the end of this field and then ignore it and move on to the next line. Can anyone help.

Cheers

Hi

lets say that this data is in a file x
then you can try this

for i in `cat x`
do
echo $i|cut -c3-
done

rgds
penguin

It faster to use the shell, if you have bash or ksh available to you:

#!/usr/bin/ksh
while read item; do
case $item in
*kg) : ;;
*) print $item ;;
esac
done < your_file >output_file

It can be done any number of ways via the shell - that is just one way.
That is also assuming that the "20kg" is either on a line by itself or at the end...

You could also do:

sed "s/.*kb$//g" your_file > output_file

I'm not sure what you are trying to end up with...but if all you were wanting was a list of rows that don't have the kg on them...

then "grep -v 'kg' > rows_without_kg"
would work.

Probably not what you are after - but if it is then this would be much quicker.