Could you please tell me solutions for the following questions .

Q1)


#!/bin/sh

while read line
do
i=$[$i+1]
array[$i]=$line
echo $i
echo ${array[$i]}
done<input.txt

echo ${array[$i]}


I need to read a file and put each line in a variale
array[0],array[1],array[2] ..........
I don't know how many lines are present in the file.


Here inside the loop it is echoing correct answer
but not outside the loop.How to declare an array with unknown size outside
the while loop


Q2)

I have the following content on a file.I need to replace '2' in each line
with a different value which are present in a file
I couldn't find a good regex for this.I tried with sed for multiple times
but not efficiently


desVar(   "wp3" *2*u      )
desVar(   "wp2" *2*u      )
desVar(   "wp1" *2*u      )
desVar(   "wp0" *2*u      )
desVar(   "wn3" *2*u      )
desVar(   "wn2" *2*u      )
desVar(   "wn1" *2*u      )
desVar(   "wn0" *2*u      )

the file content is the following ,each line contains a number

0.16
0.16
1.461
0.23604
0.16
0.16




-- 
Y.NagaMohan

--~--~---------~--~----~------------~-------~--~----~
l...@iitd mailing list -- group http://groups.google.com/group/iitdlug
-~----------~----~----~----~------~----~------~--~---

Reply via email to