Click here to Skip to main content
15,868,292 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
stuck. very stuck.
why? because i can't figure out a replacement command that works by giving an index

what i'm doing now is:
rpl "oldstring" "newstring" "filename"

ofcourse this changes all the search results.

what i need is something like this:
rpl "index" "newstring" "filename"

or
rpl "index" "oldstring" "newstring" "filename"


what i've found but doesn't work for me is:
sed '35s/.*/foo/' $filename

where 35 is the line number
and foo is the string that i want to replace the old line with
^-- works but i can't seem to figure out how to build my own string,
i've tried :
sed '${index}s/.*/${replacementline}' $filename


note: the line i'm trying to change in the file occurs several times. (i'm trying to work with an index to fix this problem, wich caused the current problem)
i've been working on this long enough now.. and i'm new to linux's commands, i haven't got the experience yet to make complex commands myself.

thanks for helping ^^!
Posted
Updated 26-May-15 2:09am
v2

1 solution

I have not tried it myself but it seems that this could help you out[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900