sed -n: Suppresses automatic printing of lines.Find and replace a file in-place
sed -i 's/ross/russ/' myFile.txt
sed -i 's|ross|russ|' myFile.txt
Find lines containing ‘x’ in a file and delete them
sed -i '/myString/d' /home/ross/myFile.txt
Return lines between the two specified. (The specified lines must exist)
sed -n '/Feb 23 13:55/,/Feb 23 14:00/p' /var/log/syslog
To display the contents of a file starting from the first line that matches a pattern
sed -n '/PATTERN/,$p' filename
/PATTERN/,$p: This is an address range. It tells sed to start printing (p) from the line containing PATTERN until the end of the file ($).Append text after matched line (including a TAB)
sed -i '/listen \[::/a\\thttp2 on;' site.conf
# For exmaple, adding 'https2 on;' to an NGINX config
server {
listen 443 http2 ssl;
listen [::]:443 http2 ssl;
http2 on;
...