Parsing file using shell script

vassim1977
vassim1977 used Ask the Experts™
on
Hi i need a shell script to parse a file line by line .

//////////////////////////input file//////////////////////////
Service A Running :00
Service B Running :00
Service C Running :00
..
.
Total Running :00
///////////////////////////////////////////////////////

I need to read this file line by line saving each line into 2 variables var1 and var2
where var1 = "Service A Running and" var2 = ":00" please note second variable can be of format
":00" , "1:02" , "25:10" etc .. and first variable can consists from strings separated by withe spaces .

thats what i did so far is but stuck on parsing part and saving variables
/////////////////////////////////////////////////
cat inputfile | while read line;
do
 echo "$line"  ;
done
/////////////////////////////////////////////////

thaks in advance





 
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2014
Top Expert 2015
Commented:
#!/bin/bash
cat inputfile | while read line;
do
 echo "$line"  ;
 var1=${line% *}
 var2=${line##* }
done

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial