Alternate way for echo.

Hi,
Is there any other command echo does.

if [ `echo $line|grep "^$companyHdrRecord"| wc -l` -ne 0 ]

I am doing this operation for each line in my file. So its taking very long time to process more than 1000 records.

Is there any alternative way to write the above if statement

Perhaps this. Not tested tho'

while read line
do
  if [[ $line == "$companyHdrRecord*" ]] ; then
    echo $line
  fi
done < input.txt

I guess the problem might be the way you are using loop to get lines one by one.

if you are using loop like

cat filename| while read line
 do
 .....
 .....

 done

then instead use the below method

while read line
 do
 ...
 ...
 done < filename

This will reduce your loop proccessing time.

Hi,

grep "^${companyHdrRecord}" inputfile| while read line
do
#Operations
echo $line
done

You might want to read "12 ways to parse a file" about the topic.

bakunin

Those 12 ways to parse a file is really good stuff.I would like to thanks google for sharing with all of us.(Before that i never given thought which one is better)

The method i suggested is one of those 12 ways and it is claimed to be one of the two better performers.