Top "Sed" questions

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

Shell script - remove first and last quote (") from a variable

Below is the snippet of a shell script from a larger script. It removes the quotes from the string that …

string bash shell unix sed
How to remove all white spaces from a given text file

I want to remove all the white spaces from a given text file. Is there any shell command available for …

linux bash sed
How to replace an entire line in a text file by line number

I have a situation where I want a bash script to replace an entire line in a file. The line …

bash text replace sed
How to insert a text at the beginning of a file?

So far I've been able to find how to add a line at the beginning of a file but that's …

linux bash sed
How do I remove newlines from a text file?

I have the following data, and I need to put it all into one line. I have this: 22791 ; 14336 ; 22821 ; 34653 ; 21491 ; 25522 ; 33238 ; I need …

linux bash scripting shell sed
How to insert a newline in front of a pattern?

How to insert a newline before a pattern within a line? For example, this will insert a newline behind the …

shell sed
Add text at the end of each line

I'm on Linux command line and I have file with 127.0.0.1 128.0.0.0 121.121.33.111 I want 127.0.0.1:80 128.0.0.0:80 121.121.33.111:80 I remember my colleagues were using sed for …

sed
Delete specific line number(s) from a text file using sed?

I want to delete one or more specific line numbers from a file. How would I do this using sed?

unix sed line-numbers
Environment variable substitution in sed

If I run these commands from a script: #my.sh PWD=bla sed 's/xxx/'$PWD'/' ... $ ./my.sh …

linux unix shell sed
Find and replace with sed in directory and sub directories

I run this command to find and replace all occurrences of 'apple' with 'orange' in all files in root of …

linux command-line sed replace