15 examples for sed
# Replace all 'dog' with 'cat' in file.txt, and keep the original in file.txt.orig sed -i.orig s/dog/cat/g file.txt
# print all lines from production.log matching the word "error", plus 1 additional line sed -n '/error/,+1p' production.log
# remove blank lines from from a text file sed '/^[[:space:]]*$/d' input.txt > output.txt
# print the lines from somefile.txt matching the word "fromText" to the first line that matches "toText" sed -n '/fromText/ , /toText/p' somefile.txt
# Find and replace all instances of FOO with BAR in all matching files. find . -type f -print | xargs sed -i 's/FOO/BAR/g'
# search and replace, inplace ** forward slashes ** sed -i 's|~|/home/user|' list of files
# remove multiple blank (empty) lines from file and stores result in new file sed '/^\s*$/d' input > output
# Convierte la primera letra de una lista de caracteres en mayuscula cat filename | sed 's/./\u&/' # Salida # Juan # Diego # Ernesto # Gerardo # David