sed 'y/string/STRING/g' # Replace s -> S, t -> T, r -> R ‥‥
sed 's/string/STRING/g' # Replace "string" -> "STRING".
sed 's/string/STRING/' # Only replace the first "string" to "STRING" in a row.
sed 's/^string/STRING/' # Only replace the "string" to "STRING" if it starts with the line head.
sed 's/string$/STRING/' # Only replace the "string" to "STRING" if it's end with the tail of a line.
sed 's/string//g' # Remove "string" from a row.
sed 's/^$//g' # Remove empty row.
sed 's/^.....//' # Remove 5 characters from the line head.
sed -n '/string/p' # Print a row which is including "string".
sed '/string/d' # Delete a row which is including "string".
sed '5,35s/string$/STRING/' # Only process from line 5th to line 35th.
sed '5,$s/string$/STRING/' # Process from line 5th.
sed -n '/^I/p' # Only print a row started with "I".
sed '$d' # Delete the last row.
sed '$-5,$d' # Delete the last 5 rows.
sed -e "s/\.txt/.doc/" # Replace ".txt" to ".doc".
$ file_name="linux.txt" $ echo $file_name | sed -e "s/\.txt/.doc/" linux.doc
sed -e "s/\.[^.]*$//g" # Remove ".${anyString}".
$ file_name="linux.txt" $ echo $file_name | sed -e "s/\.[^.]*$//g" linux $ file_name="linux..txt" $ echo $file_name | sed -e "s/\.[^.]*$//g" linux.
sed -e "s/.*\.\([^.]*\)\$/\1/g" # Print special string such as a filename extension.
$ file_name="linux.txt" $ echo $file_name | sed -e "s/.*\.\([^.]*\)\$/\1/g" txt