Posts

Showing posts with the label append

Linux: Working with sed

Working with sed (a stream editor)   At some point I had to modify the configuration of multiple nginx configuration files, replacing on all of them a specific string with another one, commenting some strings, deleting some other strings, on one of my CentOS machines.   If I would go to edit manually file by file, it would take a few hours, at least.   So, I choose to use sed and to edit all files at the same time and in order to explain, I creates 100 files containing the same string, I'm using "tee" command: johnyc20@centos:~$ echo "fastcgi_pass 127.0.0.1:9501;"  | tee site-name-{1..100}.conf   Now I have 100 files containg the "fastcgi_pass 127.0.0.1:9501;": johnyc20@centos:~$ cat site-name-* fastcgi_pass          127.0.0.1:9501;   Now I will explain: How to replace content How to comment lines How to insert lines  How to delete lines Short summary of sed options How to replace content The first thing, I am replacing t