Home » Infrastructure » Unix » Extract string and values from a line using shell
Extract string and values from a line using shell [message #97030] Fri, 26 October 2001 06:08 Go to next message
Laxsun
Messages: 10
Registered: October 2001
Junior Member
Some one can help me to extract the following values
from the below given line of text (sinple line) usning
shell scripting.

I) Values to be extracted:
1) Growth Rate
2) -445.00%
3) -1,140.00%
4) 33.75%
5) 38.81%

II) Line of text(single line):

< color=#FF0000>-0.74<f<T<>R><D AL=LEFT>Growth Rate</T<D ALI=RIGT>&bsp;&bsp;&bsp;<fot cor=#FF0000>-445.00%</fot<D<D ALN=RGT>&bp;&bp;&bp;<fnt cor=#FF0000>-1,140.00%</ft<D<D ALGN=RIT>&bp;&sp;&np;33.75%<D<D AGN=RHT>&bp;&bs;&bs;38.81%<D></R><ALE></D><R></AE><N CS=noal>Zacks Industry: TELECOMM EQUI

Thanks in advance.
Laxsun

----------------------------------------------------------------------
Re: Extract string and values from a line using shell [message #97031 is a reply to message #97030] Fri, 26 October 2001 07:54 Go to previous messageGo to next message
Dinesh C Sivasankaran
Messages: 2
Registered: October 2001
Junior Member
Here you go !!! ( This is one way of doing ).

Shell ( Ksh ) starts here ...

while read current_line
do
str1=$(print $current_line | cut -c24-34 )
str2=$(print $current_line | cut -c50-57 )
str3=$(print $current_line | cut -c70-79 )
str4=$(print $current_line | cut -c92-97 )
str5=$(print $current_line | cut -c110-115 )
print -R "-->$str1<==>$str2<==>$str3<==>$str4<==>$str5<--"
done < summa ;

Shell ends here.

where summa is the file in which you have the pattern ... you can always have the pattern in the same shell.

Hope this would be useful !!!

Good luck
dinesh ...

----------------------------------------------------------------------
Re: Extract string and values from a line using shell [message #97042 is a reply to message #97030] Mon, 29 October 2001 18:36 Go to previous message
Laxsun
Messages: 10
Registered: October 2001
Junior Member
Thanks Dinesh, it's really helped timely.

----------------------------------------------------------------------
Previous Topic: ora 00443
Next Topic: Re: Problem Installation 8i on Linux
Goto Forum:
  


Current Time: Thu Oct 01 03:44:57 CDT 2020