Reputation: 11
I have a specific requirement.
I have file:
some text
. . . . .
. . . . .
**todo: owner comments . . . .**
... .
sometext
Now I want the output like:
some text
. . . . .
. . . . .
**todo: owner comments . . . .**
**owner: todo comments . . . .**
... .
.
sometext
I want to grep for todo and copy that line and paste it below with above modification. Can it be possible without opening a file... like sed,awk command ??
Thanks and Regards, Dharak
Upvotes: 0
Views: 499
Reputation: 264
sed 's/\(**todo: owner comments\)\(.*\)/\1 \2 \
> **owner: todo comments \2/g' filename
Upvotes: 0
Reputation: 67467
I guess what you mean is opening the file in an editor. Here is an awk script you can tailor for your needs.
$ awk '/\*\*todo:/{print; print "**owner: todo ... ";next}1' file
some text
. . . . .
. . . . .
**todo: owner comments . . . .**
**owner: todo ...
... .
sometext
you can save the output to a temp file and move over to your original file.
Upvotes: 1