What are the core `sed` commands you use in automation?
BeginnerConceptText processing: grep, sed, awk, cut, sort, uniq
Answer
sed 's/old/new/' # first match per line
sed 's/old/new/g' # all matches
sed -n '5,10p' # print only lines 5-10
sed '/^#/d; /^$/d' # delete comments and blank lines
sed -i.bak 's/^LogLevel .*/LogLevel INFO/' app.conf # edit in place, keep backup
sed -E 's/([0-9]+)ms/\1 ms/g' # ERE with capture group
sed '/\[mysqld\]/a max_connections = 500' my.cnf # append after match (GNU)
sed 's|/var/www|/srv/www|g' # alternate delimiter for paths
sed is line-oriented: perfect for substitutions and filtering, awkward for multi-line or column logic (use awk).
More on Text processing: grep, sed, awk, cut, sort, uniq
What are the most useful `grep` flags?BeginnerWhat is the difference between basic, extended and Perl regular expressions in grep?IntermediateWhy does `sed -i` behave differently on macOS and Linux?IntermediateHow do you use variables inside a `sed` expression safely?AdvancedWhat is the structure of an `awk` program?BeginnerHow do you count occurrences per key with `awk` associative arrays?Intermediate