Name: Tom Date: August 16, 2002 at 08:38:23 Pacific Subject: Tell Numeric from Char in Unix script
Comment:
Hi,
I am having a problem determinig how to write an awk script that will do the following.
I have a file and in that file I am looking at a certain field. This field will contain one of tow things. All numbers or a cobination of numbers and chars. If I see chars in the field I want to append 10 space to the left of the field. If I see that the field has all numbers, then I ignore it and go to the next record.
I can hanlde the apeend of 10 spaces etc. What I do not know is if there is a way to tell a number from a char in a text file.
Is there a way to know that "2" is a number and "B" is a letter?
if [ "$Let_Field" -eq "$Let_Field" 2>/dev/null ] then echo "It Is Numeric" echo "Do Whatever you want to do" else echo "It Is Not Numeric" echo "Do Whatever you want to do" fi
If I am looking at a string of 7 characters in field 3 or $3. And I search for [a-zA-z] I can return $3 with 10 spaces.
But I only want 10 spaces at the back end of the 7 char string if chars are found. So How do I do the if in awk?
I.E. if the filed contains "12T4567" then I want to return to a file "12T4567 " but if the field is "1234567" I want to return "1234567". SO I just do not want to find only the rcords with chars I want all records. Just want to manipulate the ones with chars.
I.E. if the filed contains "12T4567" then I want to return to a file "12T4567 " but if the field is "1234567" I want to return "1234567". SO I just do not want to find only the rcords with chars I want all records. Just want to manipulate the ones with chars.