sed with -e option

sed "s/^/8,A1,$dat,id2_3,/g" -e sed "s/$/,,,,,,,,,,,/g" temporary

[/CODE]

wn m running this script m getting a error... plz help me with this....

O/p

sed: -e expression #1, char 3: unterminated `s' command

---------- Post updated at 11:35 AM ---------- Previous update was at 11:33 AM ----------

m done thanks for ur views :stuck_out_tongue:

try this..

 
sed "s/^/8,A1,$dat,id2_3,/g" -e "s/$/,,,,,,,,,,,/g" temporary

had given a sed extra :stuck_out_tongue:

correct format

sed "s/^/8,A1,$dat,id2_3,/g" -e "s/$/,,,,,,,,,,,/g" temporary

---------- Post updated at 11:40 AM ---------- Previous update was at 11:36 AM ----------

got stuck with one more error

sed: can't read s/^/8,A1,2012-12-20,id2_3/g: No such file or directory

missing the -e

sed -e "s/^/8,A1,$dat,id2_3,/g" -e "s/$/,,,,,,,,,,,/g" temporary
sed -n -i -e "1,$record s/^/8,A1,$dat,$service,/g" -n -i -e "1,$record s/$/,,,,,,,,,,,,,/g" temporary $service.txt

throws this error

sed: -e expression #1, char 4: unexpected `,'

---------- Post updated 12-21-12 at 10:18 AM ---------- Previous update was 12-20-12 at 12:29 PM ----------

sed -n -i -e "1,$record s/^/8,A1,$dat,$service,/g" -n -i -e "1,$record s/$/,,,,,,,,,,,,,/g" temporary $service.txt

[/CODE]

when i execute above script it gives me below error .... rectify my error

sed: -e expression #1, char 4: unexpected `,'

what you are trying to do ?

can you post the input file and the expected output data.

i/p file is given below...

first column is counter it will keep increamenting

I don't find any error whilst doing in my terminal. Just curious how your 8,A1 is incrementing your index.

Rather use

sed = (or) nl+tr
# echo $date
Fri Dec 21 12:06:55 IST 2012


# echo $service
id2_3


# echo $record
8

# sed -e "1,$record s/^/8,A1,$date,$service,/g" -e "1,$record s/$/,,,,,,,,,,,,,
/g" file
8,A1,Fri Dec 21 12:06:55 IST 2012,id2_3,919795266672,CocAY02XIxhv5OcfMKOisi9tLHA
=,phoneX1-01,ID,,,,,,,,,,,,,
8,A1,Fri Dec 21 12:06:55 IST 2012,id2_3,919999161967,qy1yiib/yHpw6epIGwa5fRRxxPg
=,phoneX1-01,VO,,,,,,,,,,,,,
8,A1,Fri Dec 21 12:06:55 IST 2012,id2_3,919436066755,zQsaHc813zTiH2uFsc4RCY+odJA
=,phoneX1-01,BL,,,,,,,,,,,,,
8,A1,Fri Dec 21 12:06:55 IST 2012,id2_3,918507101556,46c3BhiEXDSUQuQxYgvzDDqeLDw
=,phone101,AL,,,,,,,,,,,,,
8,A1,Fri Dec 21 12:06:55 IST 2012,id2_3,919918352008,dKsdIY0vKNoA0g7UJuKlq9dzpJM
=,phoneX1-01,VO,,,,,,,,,,,,,
8,A1,Fri Dec 21 12:06:55 IST 2012,id2_3,919767180955,0358639040055082,phoneC2-03
,ID,,,,,,,,,,,,,
8,A1,Fri Dec 21 12:06:55 IST 2012,id2_3,918730997431,LBdhdvUGZxxHzJKqCGrD94o/41I
=,phoneX1-01,AIL,,,,,,,,,,,,,
8,A1,Fri Dec 21 12:06:55 IST 2012,id2_3,919716378453,T72dXAZXQTt1ZgYqhCV/XIGVlo8
=,phoneX1-01,AL,,,,,,,,,,,,,
919414277744,WZt+OGw2zCqzY4hfg67/zOrEuDk=,phone101,BL
918760099656,f0YvNzqqvtyLwuY622MO+ngW7PY=,phoneX1-01,AL

---------- Post updated at 01:51 AM ---------- Previous update was at 01:38 AM ----------

Probably removing the -n will work