I want to replace a string "#security" with "security\n\tauthorization : enabled" in a file file.txt. Here \n represents a new line and \t for tab. How can I do this using sed command.
Asked
Active
Viewed 402 times
0
-
2Seems like a homework question... – Severus Tux Jul 01 '16 at 05:32
-
This is very basic. There's tons and tons of similar questions that has been asked , and there's tons and tons of resources for basic `sed` on google. Do your research. We are not free "do my homework" service – Sergiy Kolodyazhnyy Jul 01 '16 at 05:46
-
I'm voting to close this question as off-topic because it seems like homework – Sergiy Kolodyazhnyy Jul 01 '16 at 05:46
1 Answers
1
sed 's/#security/security\n\tauthorization : enabled/' file
If you want to edit your file "in place" use sed's option -i.
See: man sed
Cyrus
- 5,394
- 2
- 19
- 31