To search a file for a specific word in a file using shell script

Hi All,
I have a sql output file has below. I want to get the values 200000040 and 1055.49 .Can anyone help me to write a shell script to get this.

ACCOUNT_NO
------------------------------------------------------------
BILL_NO PAY_TYPE
------------------------------------------------------------ ----------
AMT_NOT_BILLED CASH_ON_DELIVERY
-------------- ----------------
COD_BILL_NO IS_SUSPENDED
------------------------------------------------------------ ------------
200000040
B1-57 10005
1055.49 0
0

Thanks in Advance.
Girish.

try..

-bash-3.2$ cat list2
ACCOUNT_NO
------------------------------------------------------------
BILL_NO PAY_TYPE
------------------------------------------------------------ ----------
AMT_NOT_BILLED CASH_ON_DELIVERY
-------------- ----------------
COD_BILL_NO IS_SUSPENDED
------------------------------------------------------------ ------------
200000040
B1-57 10005
1055.49 0
0
-bash-3.2$
-bash-3.2$ sed -n '9 p' list2
200000040
-bash-3.2$ sed -n '11 p' list2
1055.49 0

or

-bash-3.2$ sed '9 !d' list2
200000040
-bash-3.2$ sed '11 !d' list2
1055.49 0
-bash-3.2$

Try this one

cat inputfile | awk -F " " '/^[[:digit:]]/ { print $1 }'

Hi ryandegrate25,
Thanks for the reply. Your command works for my requirment.
Actually i have similar kind of records in a list2, in this case how will i use your command. I tried using it but its failing for multiple records of same type(which i posted earlier).

Thanks in advance, Giri

the number in

sed '11 !d' list2

refers to line number... if your input has a fixed line numbers then you can use it else you can use pattern searching like posted by oky

Hi oky,
In your commane "cat inputfile | awk -F " " '/^[[:digit:]]/ { print $1 }' "

Can i know what does "digit" refers to.?
Actually the input file format which i had posted will have similar kind mulitple records in a file.Considering this can you help me to get a command.

Also now i tried using your above command on multiple records, it gives me only 200000040 and not the 1055.49.. Please help.

Thanks in advance.
Giri

oky's solution will apply to the whole file.
it will do the same whenever the condition matches.

to remove the last line i.e "0" you can do something like below:

awk -F " " '{ if ($0 ~ /^[[:digit:]]/ && $0 != 0) { print $1 }}' inputfile

inputfile:

ACCOUNT_NO
------------------------------------------------------------
BILL_NO PAY_TYPE
------------------------------------------------------------ ----------
AMT_NOT_BILLED CASH_ON_DELIVERY
-------------- ----------------
COD_BILL_NO IS_SUSPENDED
------------------------------------------------------------ ------------
200000040
B1-57 10005
1055.49 0
0
 
ACCOUNT_NO
------------------------------------------------------------
BILL_NO PAY_TYPE
------------------------------------------------------------ ----------
AMT_NOT_BILLED CASH_ON_DELIVERY
-------------- ----------------
COD_BILL_NO IS_SUSPENDED
------------------------------------------------------------ ------------
666666040
B1-57 10005
1088.49 0
0
 
ACCOUNT_NO
------------------------------------------------------------
BILL_NO PAY_TYPE
------------------------------------------------------------ ----------
AMT_NOT_BILLED CASH_ON_DELIVERY
-------------- ----------------
COD_BILL_NO IS_SUSPENDED
------------------------------------------------------------ ------------
222220040
B1-57 10005
3355.49 0
0

output:

200000040
1055.49
666666040
1088.49
222220040
3355.49

[[:digit:]] - a character class keyword especially to refer the digits alone

Hi All,
Thanks a lot, your code snippet worked for my requirment....

Thank,

Giri