"shell script :- urgently require help"
hello everyone,
i have to read a data from a flat file based on some line number, when the line number is known to me. so i can write command such as :- b=`sed -n -e 10p /util/xfer/trsfers/TL_MONTH1.csv` but suppose if i want to use same command inside some loop like this b=`sed -n -e $var /util/xfer/trsfers/TL_MONTH1.csv` where var=row number. this will not work why?? is it because "sed" reads data at one shot.?? can u please advise me how can i read the data inside a loop from different file based on row number.?? i badly require this . thanks in advance regards |
var=10
sed -n -e "$var"p /util/xfer/trsfers/TL_MONTH1.csv should work. |
Try quoting the variable. Also, you need the 'p' after it, unless it's included in the variable contents, that is. This worked for me:
Code:
b=`sed -n -e "$var"p /util/xfer/trsfers/TL_MONTH1.csv` |
All times are GMT -5. The time now is 07:58 PM. |