Top "Sed" questions

Sed (Stream EDitor) is a command line editor for POSIX environment.

Replace a string in shell script using a variable

I am using the below code for replacing a string inside a shell script. echo $LINE | sed -e 's/12345678/"$replace"/…

unix shell sed
How to output only captured groups with sed?

Is there any way to tell sed to output only captured groups? For example given the input: This is a …

regex sed
How to use sed to replace only the first occurrence in a file?

I would like to update a large number of C++ source files with an extra include directive before any existing #…

command-line sed text-processing
Retrieve last 100 lines logs

I need to retrieve last 100 lines of logs from the log file. I tried the sed command sed -n -e …

linux logging sed
How to replace multiple patterns at once with sed?

Suppose I have 'abbc' string and I want to replace: ab -> bc bc -> ab If I …

replace syntax sed
Replace comma with newline in sed on MacOS?

I have a file of id's that are comma separated. I'm trying to replace the commas with a new line. …

macos unix sed
Escape a string for a sed replace pattern

In my bash script I have an external (received from user) string, which I should use in sed pattern. REPLACE="&…

string sed escaping
How to replace a whole line with sed?

Suppose I have a file with lines aaa=bbb Now I would like to replace them with: aaa=xxx I …

regex sed
Insert line after first match using sed

For some reason I can't seem to find a straightforward answer to this and I'm on a bit of a …

shell sed
sed edit file in place

I am trying to find out if it is possible to edit a file in a single sed command without …

unix sed solaris