Tag Archives: sed examples

sed tutorial: sed replace

Sed replace, you can use the sed function: s, replace the text in the file. syntax: ➜ ~ sed ‘s/regexp/replacement/’ file Continue reading

Posted in Sed Command, Text Processing | Tagged , , | Comments Off on sed tutorial: sed replace

sed tutorial: sed insert line before match

Sed insert a line before match, you can use the sed function: i, add a new line before the matched string. syntax: sed ‘/option/i newLine’ file Continue reading

Posted in Sed Command, Text Processing | Tagged , , | Comments Off on sed tutorial: sed insert line before match

sed tutorial: sed add line after match

sed add line after match, you use sed function: a , to add a new line after the matched string. syntax: sed ‘/option/a newLine’ file Continue reading

Posted in Sed Command, Text Processing | Tagged , , | Comments Off on sed tutorial: sed add line after match

How to find and replace specified string with sed in linux/unix

find and replace content in linux: Use the grep command and sed command to search and replace, Use the find command and sed command to find files and replace Continue reading

Posted in How to, Sed Command, Text Processing | Tagged , , | Comments Off on How to find and replace specified string with sed in linux/unix

How to remove lines with specific line number from text file with awk or sed in Linux/unix

Remove specific line numbers in linux/unix, use awk NR variable to delete a specific line numbers, use sed command action option “d” to delete a specific line numbers Continue reading

Posted in How to, Awk Command, Sed Command, Text Processing | Tagged , , | Comments Off on How to remove lines with specific line number from text file with awk or sed in Linux/unix

sed tutorial: sed append command

The sed append command can add a new line before or after the specified matching line. We do this by using sed a and i options command. Continue reading

Posted in Sed Command, Text Processing | Tagged , , , | Comments Off on sed tutorial: sed append command

sed tutorial: sed address and address range(select lines) with examples

sed address and address range tutorial, by using addresses or address ranges, the sed command can apply certain actions to these address lines. Continue reading

Posted in Internet Technology, Sed Command, Text Processing | Tagged , , , | Comments Off on sed tutorial: sed address and address range(select lines) with examples

How to use sed to replace multiple patterns at once in linux/unix?

sed is a powerful streaming text editor, and replace pattern is one of the most used functions. This article introduces how to replace multiple patterns at once with sed. Continue reading

Posted in How to, Sed Command, Text Processing | Tagged , , | Comments Off on How to use sed to replace multiple patterns at once in linux/unix?

How to remove the first line of a text file using the linux command line?

remove the first line: use awk NR variable, awk ‘{if(NR>1){print $0}}’ file ; use sed action option d, sed ‘1d’ file; use tail n option, tail -n +2 file Continue reading

Posted in Text Processing, Awk Command, How to, Sed Command | Tagged , , , | Comments Off on How to remove the first line of a text file using the linux command line?

How to delete empty lines in a text file in linux/unix

To delete blank lines in a text file, you can use awk NF variable, awk regular expression, sed regular expression and grep -v ‘^$’ Continue reading

Posted in How to, Awk Command, Sed Command, Text Processing | Tagged , , , | Comments Off on How to delete empty lines in a text file in linux/unix

How to delete lines containing a specific string in a text file in linux/unix

Delete lines containing a specific string in a text file, we have three implementation methods: sed -i ‘/ pattern/d’, grep -v ‘pattern’ and awk ‘!/pattern/ {print $0}’ Continue reading

Posted in Text Processing, Awk Command, How to, Sed Command | Tagged , , , | Comments Off on How to delete lines containing a specific string in a text file in linux/unix

Sed command tutorial in linux/unix with examples and use cases

sed is a stream editor.

1. sed workflow
2. hold space and pattern space explain
3. sed syntax
4. sed debug tool
5. sed example
sed add/del/replace … Continue reading

Posted in Sed Command, Text Processing | Tagged , , , | Comments Off on Sed command tutorial in linux/unix with examples and use cases

How to using multiple delimiters in awk and sed

Multiple delimiter-separated fields in awk or sed.
Using awk command:
➜ awk -F'[:=|]’ ‘{print $1, $2, $3}’ test.log;
Using sed command:
➜ sed ‘s/[:=|]/ /g’ test.log Continue reading

Posted in Awk Command, File & Directory, How to, Sed Command, Text Processing | Tagged , , , , , , | 3 Comments