Skip to content



If variable has /

sed "s|$variable||g"

Replace in files

sed -i {{ sed_replace_expression }} {{ files_to_replace }}

Replace recursively in directories and subdirectories

find {{ directory }} -type f -exec sed -i 's/nano/vim/g' {} +

Non greedy

Sed doesn't support non greedy, use .[^{{ character }}]* instead

Delete line that match

sed '/<match>/d' file

Delete the last line of file

sed '$d' -i file.txt

Delete the first line of file

sed '1d' -i file.txt