{"id":890,"date":"2016-03-07T17:11:46","date_gmt":"2016-03-07T15:11:46","guid":{"rendered":"http:\/\/www.systemcodegeeks.com\/?p=890"},"modified":"2018-05-31T16:10:06","modified_gmt":"2018-05-31T13:10:06","slug":"linux-sed-examples","status":"publish","type":"post","link":"https:\/\/www.systemcodegeeks.com\/shell-scripting\/bash\/linux-sed-examples\/","title":{"rendered":"Linux sed Examples"},"content":{"rendered":"<p>In this post, we feature a comprehensive Linux sed Examples. Sed is basically a stream editor used for modifying files in unix or linux. It provides a nifty way to perform operations on files which can be passed around through pipes. Most people never learn its real power, they just simply use sed to replace text. You can do many things apart from replacing text with sed.<\/p>\n<p>As mentioned earlier, sed is an editor that allows us to use pattern matching to search and replace within a file, or an input stream. This works by using Regular Expressions. By default, the results of any edits we make to a source file, or input stream, will be sent to STDOUT, the standard output. The original file will be unaffected by the edits.<\/p>\n<p>Also the sed command can be incredibly useful when bootstrapping a new server, or machine, as it can easily be scripted. A common use case for sed is to script the editing of configuration files on a new server instance to facilitate the further setup of the needed environment for that machine.<\/p>\n<p>In this article I will describe the capabilities of sed with examples. Consider the below file as input to our examples:<\/p>\n<pre class=\"brush:bash\">&gt;cat example.txt\r\nI want to learn java. Learn java. Learn java\r\njava is the best\r\njava forever<\/pre>\n<p>[ulp id=&#8217;SG9vnnKgRCD7iZxf&#8217;]<\/p>\n<h2>1. Replacing string<\/h2>\n<p>Sed command is mostly used to replace the text in a file. The below sed command replaces the word &#8220;java&#8221; with &#8220;guava&#8221; in the file only for the first occurrence in each line:<\/p>\n<pre class=\"brush:bash\">&gt;sed 's\/java\/guava\/' example.txt<\/pre>\n<p>Here the &#8220;s&#8221; specifies the substitution operation. The &#8220;\/&#8221; are delimiters. The &#8220;java&#8221; is the search pattern and the &#8220;guava&#8221; is the replacement string.<\/p>\n<p>By default, the sed command replaces the first occurrence of the pattern in each line and it won&#8217;t replace next occurences.<\/p>\n<h2>2. Replacing the nth occurrence of a pattern in a line<\/h2>\n<p>Use the \/1, \/2 etc flags to replace the first, second occurrence of a pattern in a line. The below command replaces the second occurrence of the word &#8220;java&#8221; with &#8220;guava&#8221; in a line:<\/p>\n<pre class=\"brush:bash\">&gt;sed 's\/java\/guava\/2' example.txt<\/pre>\n<h2>3. Replacing all the occurrences of a pattern in a line<\/h2>\n<p>The substitute flag \/g (global replacement) specifies the sed command to replace all the occurrences of the string in the line:<\/p>\n<pre class=\"brush:bash\">&gt;sed 's\/java\/guava\/g' example.txt<\/pre>\n<h2>4. Replacing from nth occurrence to all occurrences in a line<\/h2>\n<p>Use the combination of \/1, \/2, \/n and \/g to replace all the patterns from the nth occurrence of a pattern in a line. The following sed command replaces from the second occurrence until the nth of the word &#8220;java&#8221; with the word &#8220;guava&#8221; in a line:<\/p>\n<pre class=\"brush:bash\">&gt;sed 's\/java\/guava\/2g' example.txt<\/pre>\n<h2>5. Duplicating the replaced line with \/p flag<\/h2>\n<p>The \/p print flag prints the replaced line twice on the terminal. If a line does not have the search pattern and is not replaced, then the \/p prints that line only once.<\/p>\n<pre class=\"brush:bash\">&gt;sed 's\/java\/guava\/p' example.txt<\/pre>\n<p>The below image illustrates the execution of the first 5 sed commands:<\/p>\n<figure id=\"attachment_914\" aria-describedby=\"caption-attachment-914\" style=\"width: 860px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/03\/sed__1-5.jpg\" rel=\"attachment wp-att-914\"><img decoding=\"async\" class=\"wp-image-914 size-full\" src=\"http:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/03\/sed__1-5.jpg\" alt=\"Linux sed Examples: Sed Examples 1-5\" width=\"860\" height=\"611\" srcset=\"https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/03\/sed__1-5.jpg 860w, https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/03\/sed__1-5-300x213.jpg 300w, https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/03\/sed__1-5-768x546.jpg 768w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/a><figcaption id=\"caption-attachment-914\" class=\"wp-caption-text\">Sed Examples 1-5<\/figcaption><\/figure>\n<h2>6. Replacing string on a specific line number<\/h2>\n<p>You can restrict the sed command to replace the string on a specific line number. The below sed command replaces the string &#8220;java&#8221; only on the second line:<\/p>\n<pre class=\"brush:bash\">&gt;sed '2 s\/java\/guava\/' example.txt<\/pre>\n<h2>7. Replacing string on a range of lines<\/h2>\n<p>You can specify a range of line numbers to the sed command for replacing a string. Here the sed command replaces the lines with range from 1 to 3. You may use the $ operator to indicate the last line in the file:<\/p>\n<pre class=\"brush:bash\">&gt;sed '1,$ s\/java\/guava\/' example.txt<\/pre>\n<h2>8. Replacing on a line which matches a pattern<\/h2>\n<p>You can specify a pattern to the sed command to match in a line. If the pattern match occurs, then the sed command looks only for the string to be replaced and if it finds it, then it replaces the string. Here the sed command first looks for the lines which have the pattern &#8220;java&#8221; and then replaces the word &#8220;java&#8221; with &#8220;guava&#8221;.<\/p>\n<pre class=\"brush:bash\">&gt;sed '\/java\/ s\/java\/guava\/' example.txt<\/pre>\n<h2>9. Deleting lines<\/h2>\n<p>You can delete the lines of a file by specifying the line number or a range of numbers:<\/p>\n<pre class=\"brush:bash\">&gt;sed '2 d' example.txt<\/pre>\n<pre class=\"brush:bash\">&gt;sed '1,$ d' example.txt<\/pre>\n<h2>10. Duplicating lines<\/h2>\n<p>You can use the sed command to print each line of a file two times:<\/p>\n<pre class=\"brush:bash\">&gt;sed 'p' example.txt<\/pre>\n<p>The below image illustrates the execution of the previous 5 sed commands:<\/p>\n<figure id=\"attachment_902\" aria-describedby=\"caption-attachment-902\" style=\"width: 860px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/03\/sed_6-10.jpg\" rel=\"attachment wp-att-902\"><img decoding=\"async\" class=\"wp-image-902 size-full\" src=\"http:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/03\/sed_6-10.jpg\" alt=\"Linux sed Examples: Sed Examples 6-10\" width=\"860\" height=\"632\" srcset=\"https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/03\/sed_6-10.jpg 860w, https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/03\/sed_6-10-300x220.jpg 300w, https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/03\/sed_6-10-768x564.jpg 768w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/a><figcaption id=\"caption-attachment-902\" class=\"wp-caption-text\">Sed Examples 6-10<\/figcaption><\/figure>\n<h2>11. Changing the slash (\/) delimiter<\/h2>\n<p>You can use any delimiter other than the slash. As an example if you want to change the web url to another url, using too many backslashes makes the sed command look awkward. In this case we can change the delimiter to another character as shown in the below example:<\/p>\n<pre class=\"brush:bash\">&gt;sed 's_http:\/\/_www_' example.txt<\/pre>\n<h2>12. Using &amp; as the matched string<\/h2>\n<p>There might be cases where you want to search for the pattern and replace that pattern by adding some extra characters to it. In such cases &amp; comes in handy. The &amp; represents the matched string:<\/p>\n<pre class=\"brush:bash\">&gt;sed 's\/java\/{&amp;}\/' example.txt<\/pre>\n<h2>13. Using \\1,\\2 and so on to \\9<\/h2>\n<p>The first pair of parenthesis specified in the pattern represents the \\1, the second represents the \\2 and so on. The \\1,\\2 can be used in the replacement string to make changes to the source string. As an example, if you want to replace the word &#8220;java&#8221; in a line with twice as the word like &#8220;javajava&#8221; use the sed command as below:<\/p>\n<pre class=\"brush:bash\">&gt;sed 's\/\\(java\\)\/\\1\\1\/' example.txt<\/pre>\n<h2>14. Running multiple sed commands<\/h2>\n<p>You can run multiple sed commands by piping the output of one sed command as input to another sed command. Sed provides also an -e option to run multiple sed commands in a single sed command:<\/p>\n<pre class=\"brush:bash\">&gt;sed 's\/java\/guava\/' example.txt | sed 's\/guava\/python\/'<\/pre>\n<pre class=\"brush:bash\">&gt;sed -e 's\/java\/guava\/' -e 's\/guava\/python\/' example.txt<\/pre>\n<h2>15. Printing only the replaced lines<\/h2>\n<p>Use the -n option along with the \/p print flag to display only the replaced lines. Here the -n option suppresses the duplicate rows generated by the \/p flag and prints the replaced lines only one time:<\/p>\n<pre class=\"brush:bash\">&gt;sed -n 's\/java\/guava\/p' example.txt<\/pre>\n<p>The below image illustrates the execution of the previous 5 sed commands:<\/p>\n<figure id=\"attachment_903\" aria-describedby=\"caption-attachment-903\" style=\"width: 860px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/03\/sed_11-15.jpg\" rel=\"attachment wp-att-903\"><img decoding=\"async\" class=\"wp-image-903 size-full\" src=\"http:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/03\/sed_11-15.jpg\" alt=\"Linux sed Examples: Sed Examples 11-15\" width=\"860\" height=\"600\" srcset=\"https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/03\/sed_11-15.jpg 860w, https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/03\/sed_11-15-300x209.jpg 300w, https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/03\/sed_11-15-768x536.jpg 768w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/a><figcaption id=\"caption-attachment-903\" class=\"wp-caption-text\">Sed Examples 11-15<\/figcaption><\/figure>\n<h2>16. Using sed as grep<\/h2>\n<p>You can make sed command to work as similar to grep command. Here the sed command looks for the pattern &#8220;java&#8221; in each line of a file and prints those lines that have the pattern:<\/p>\n<pre class=\"brush:bash\">&gt;grep 'java' example.txt<\/pre>\n<pre class=\"brush:bash\">&gt;sed -n '\/java\/ p' example.txt<\/pre>\n<h2>17. Adding a line after a match is found.<\/h2>\n<p>The sed command can add a new line after a pattern match is found. The &#8220;a&#8221; command to sed tells it to add a new line after a match is found:<\/p>\n<pre class=\"brush:bash\">&gt;sed '\/java\/ a \"Add a new line\"' example.txt<\/pre>\n<h2>18. Adding a line before a match<\/h2>\n<p>The sed command can add a new line before a pattern match is found. The &#8220;i&#8221; command to sed tells it to add a new line before a match is found:<\/p>\n<pre class=\"brush:bash\">&gt;sed '\/java\/ i \"New line\"' example.txt<\/pre>\n<h2>19. Changing a line<\/h2>\n<p>The sed command can be used to replace an entire line with a new line if a match is found. The &#8220;c&#8221; command to sed tells it to change the line.<\/p>\n<pre class=\"brush:bash\">&gt;sed '\/java\/ c \"Change line\"' example.txt<\/pre>\n<h2>20. Transforming like tr command<\/h2>\n<p>The sed command can be used to convert the lower case letters to upper case letters by using the transform &#8220;y&#8221; option. In the below example the sed command transforms the alphabets &#8220;av&#8221; into their uppercase format &#8220;AV&#8221;<\/p>\n<pre class=\"brush:bash\">&gt;sed 'y\/av\/AV\/' example.txt<\/pre>\n<p>The below image illustrates the execution of the last 5 sed commands:<\/p>\n<figure id=\"attachment_904\" aria-describedby=\"caption-attachment-904\" style=\"width: 860px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/03\/sed_16-20.jpg\" rel=\"attachment wp-att-904\"><img decoding=\"async\" class=\"wp-image-904 size-full\" src=\"http:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/03\/sed_16-20.jpg\" alt=\"Linux sed Examples: Sed Examples 16-20\" width=\"860\" height=\"548\" srcset=\"https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/03\/sed_16-20.jpg 860w, https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/03\/sed_16-20-300x191.jpg 300w, https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/03\/sed_16-20-768x489.jpg 768w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/a><figcaption id=\"caption-attachment-904\" class=\"wp-caption-text\">Sed Examples 16-20<\/figcaption><\/figure>\n<h2>Man sed<\/h2>\n<p>We tried to present some basic examples of using the sed command. Of course you may always use the man command to find the full functionality of the sed command:<\/p>\n<pre class=\"brush:bash\">&gt;man sed<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>In this post, we feature a comprehensive Linux sed Examples. Sed is basically a stream editor used for modifying files in unix or linux. It provides a nifty way to perform operations on files which can be passed around through pipes. Most people never learn its real power, they just simply use sed to replace &hellip;<\/p>\n","protected":false},"author":13,"featured_media":185,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19],"tags":[],"class_list":["post-890","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-bash"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Linux sed Examples - System Code Geeks - 2026<\/title>\n<meta name=\"description\" content=\"Interested to learn more about Linux sed? Then check out our detailed Linux sed Examples where we will try to describe the capabilities of sed with examples.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.systemcodegeeks.com\/shell-scripting\/bash\/linux-sed-examples\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Linux sed Examples - System Code Geeks - 2026\" \/>\n<meta property=\"og:description\" content=\"Interested to learn more about Linux sed? Then check out our detailed Linux sed Examples where we will try to describe the capabilities of sed with examples.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.systemcodegeeks.com\/shell-scripting\/bash\/linux-sed-examples\/\" \/>\n<meta property=\"og:site_name\" content=\"System Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/systemcodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2016-03-07T15:11:46+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-05-31T13:10:06+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/01\/bash-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Nassos Hasiotis\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@systemcodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@systemcodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Nassos Hasiotis\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.systemcodegeeks.com\/shell-scripting\/bash\/linux-sed-examples\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.systemcodegeeks.com\/shell-scripting\/bash\/linux-sed-examples\/\"},\"author\":{\"name\":\"Nassos Hasiotis\",\"@id\":\"https:\/\/www.systemcodegeeks.com\/#\/schema\/person\/d9f94ea381f1a5d535cec1c751e2461b\"},\"headline\":\"Linux sed Examples\",\"datePublished\":\"2016-03-07T15:11:46+00:00\",\"dateModified\":\"2018-05-31T13:10:06+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.systemcodegeeks.com\/shell-scripting\/bash\/linux-sed-examples\/\"},\"wordCount\":1200,\"commentCount\":3,\"publisher\":{\"@id\":\"https:\/\/www.systemcodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.systemcodegeeks.com\/shell-scripting\/bash\/linux-sed-examples\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/01\/bash-logo.jpg\",\"articleSection\":[\"BASH\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.systemcodegeeks.com\/shell-scripting\/bash\/linux-sed-examples\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.systemcodegeeks.com\/shell-scripting\/bash\/linux-sed-examples\/\",\"url\":\"https:\/\/www.systemcodegeeks.com\/shell-scripting\/bash\/linux-sed-examples\/\",\"name\":\"Linux sed Examples - System Code Geeks - 2026\",\"isPartOf\":{\"@id\":\"https:\/\/www.systemcodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.systemcodegeeks.com\/shell-scripting\/bash\/linux-sed-examples\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.systemcodegeeks.com\/shell-scripting\/bash\/linux-sed-examples\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/01\/bash-logo.jpg\",\"datePublished\":\"2016-03-07T15:11:46+00:00\",\"dateModified\":\"2018-05-31T13:10:06+00:00\",\"description\":\"Interested to learn more about Linux sed? Then check out our detailed Linux sed Examples where we will try to describe the capabilities of sed with examples.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.systemcodegeeks.com\/shell-scripting\/bash\/linux-sed-examples\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.systemcodegeeks.com\/shell-scripting\/bash\/linux-sed-examples\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.systemcodegeeks.com\/shell-scripting\/bash\/linux-sed-examples\/#primaryimage\",\"url\":\"https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/01\/bash-logo.jpg\",\"contentUrl\":\"https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/01\/bash-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.systemcodegeeks.com\/shell-scripting\/bash\/linux-sed-examples\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.systemcodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Shell Scripting\",\"item\":\"https:\/\/www.systemcodegeeks.com\/category\/shell-scripting\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"BASH\",\"item\":\"https:\/\/www.systemcodegeeks.com\/category\/shell-scripting\/bash\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Linux sed Examples\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.systemcodegeeks.com\/#website\",\"url\":\"https:\/\/www.systemcodegeeks.com\/\",\"name\":\"System Code Geeks\",\"description\":\"Operating System Developers Resource Center\",\"publisher\":{\"@id\":\"https:\/\/www.systemcodegeeks.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.systemcodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.systemcodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/www.systemcodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.systemcodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/www.systemcodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/systemcodegeeks\",\"https:\/\/x.com\/systemcodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.systemcodegeeks.com\/#\/schema\/person\/d9f94ea381f1a5d535cec1c751e2461b\",\"name\":\"Nassos Hasiotis\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.systemcodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/5150c6873ee61791052d3faf00e804497c2cc4d613d5f6c67e00dc09ee794fdc?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/5150c6873ee61791052d3faf00e804497c2cc4d613d5f6c67e00dc09ee794fdc?s=96&d=mm&r=g\",\"caption\":\"Nassos Hasiotis\"},\"description\":\"Nassos has graduated from Computer Engineering and Informatics Department in the University of Patras. He also holds a Master degree in Communication and Network Systems from University of Athens. He has a 10-year work experience as a Java and C++ developer in the Telecommunication and IT industry participating in various projects. He currently works as a senior software developer in the IT sector where he is mainly involved with projects for the EU requiring extensive java skills.\",\"sameAs\":[\"http:\/\/www.systemcodegeeks.com\/\"],\"url\":\"https:\/\/www.systemcodegeeks.com\/author\/nassos-hasiotis\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Linux sed Examples - System Code Geeks - 2026","description":"Interested to learn more about Linux sed? Then check out our detailed Linux sed Examples where we will try to describe the capabilities of sed with examples.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.systemcodegeeks.com\/shell-scripting\/bash\/linux-sed-examples\/","og_locale":"en_US","og_type":"article","og_title":"Linux sed Examples - System Code Geeks - 2026","og_description":"Interested to learn more about Linux sed? Then check out our detailed Linux sed Examples where we will try to describe the capabilities of sed with examples.","og_url":"https:\/\/www.systemcodegeeks.com\/shell-scripting\/bash\/linux-sed-examples\/","og_site_name":"System Code Geeks","article_publisher":"https:\/\/www.facebook.com\/systemcodegeeks","article_published_time":"2016-03-07T15:11:46+00:00","article_modified_time":"2018-05-31T13:10:06+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/01\/bash-logo.jpg","type":"image\/jpeg"}],"author":"Nassos Hasiotis","twitter_card":"summary_large_image","twitter_creator":"@systemcodegeeks","twitter_site":"@systemcodegeeks","twitter_misc":{"Written by":"Nassos Hasiotis","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.systemcodegeeks.com\/shell-scripting\/bash\/linux-sed-examples\/#article","isPartOf":{"@id":"https:\/\/www.systemcodegeeks.com\/shell-scripting\/bash\/linux-sed-examples\/"},"author":{"name":"Nassos Hasiotis","@id":"https:\/\/www.systemcodegeeks.com\/#\/schema\/person\/d9f94ea381f1a5d535cec1c751e2461b"},"headline":"Linux sed Examples","datePublished":"2016-03-07T15:11:46+00:00","dateModified":"2018-05-31T13:10:06+00:00","mainEntityOfPage":{"@id":"https:\/\/www.systemcodegeeks.com\/shell-scripting\/bash\/linux-sed-examples\/"},"wordCount":1200,"commentCount":3,"publisher":{"@id":"https:\/\/www.systemcodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.systemcodegeeks.com\/shell-scripting\/bash\/linux-sed-examples\/#primaryimage"},"thumbnailUrl":"https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/01\/bash-logo.jpg","articleSection":["BASH"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.systemcodegeeks.com\/shell-scripting\/bash\/linux-sed-examples\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.systemcodegeeks.com\/shell-scripting\/bash\/linux-sed-examples\/","url":"https:\/\/www.systemcodegeeks.com\/shell-scripting\/bash\/linux-sed-examples\/","name":"Linux sed Examples - System Code Geeks - 2026","isPartOf":{"@id":"https:\/\/www.systemcodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.systemcodegeeks.com\/shell-scripting\/bash\/linux-sed-examples\/#primaryimage"},"image":{"@id":"https:\/\/www.systemcodegeeks.com\/shell-scripting\/bash\/linux-sed-examples\/#primaryimage"},"thumbnailUrl":"https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/01\/bash-logo.jpg","datePublished":"2016-03-07T15:11:46+00:00","dateModified":"2018-05-31T13:10:06+00:00","description":"Interested to learn more about Linux sed? Then check out our detailed Linux sed Examples where we will try to describe the capabilities of sed with examples.","breadcrumb":{"@id":"https:\/\/www.systemcodegeeks.com\/shell-scripting\/bash\/linux-sed-examples\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.systemcodegeeks.com\/shell-scripting\/bash\/linux-sed-examples\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.systemcodegeeks.com\/shell-scripting\/bash\/linux-sed-examples\/#primaryimage","url":"https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/01\/bash-logo.jpg","contentUrl":"https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/01\/bash-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.systemcodegeeks.com\/shell-scripting\/bash\/linux-sed-examples\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.systemcodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Shell Scripting","item":"https:\/\/www.systemcodegeeks.com\/category\/shell-scripting\/"},{"@type":"ListItem","position":3,"name":"BASH","item":"https:\/\/www.systemcodegeeks.com\/category\/shell-scripting\/bash\/"},{"@type":"ListItem","position":4,"name":"Linux sed Examples"}]},{"@type":"WebSite","@id":"https:\/\/www.systemcodegeeks.com\/#website","url":"https:\/\/www.systemcodegeeks.com\/","name":"System Code Geeks","description":"Operating System Developers Resource Center","publisher":{"@id":"https:\/\/www.systemcodegeeks.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.systemcodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.systemcodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.systemcodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.systemcodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.systemcodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/systemcodegeeks","https:\/\/x.com\/systemcodegeeks"]},{"@type":"Person","@id":"https:\/\/www.systemcodegeeks.com\/#\/schema\/person\/d9f94ea381f1a5d535cec1c751e2461b","name":"Nassos Hasiotis","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.systemcodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/5150c6873ee61791052d3faf00e804497c2cc4d613d5f6c67e00dc09ee794fdc?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/5150c6873ee61791052d3faf00e804497c2cc4d613d5f6c67e00dc09ee794fdc?s=96&d=mm&r=g","caption":"Nassos Hasiotis"},"description":"Nassos has graduated from Computer Engineering and Informatics Department in the University of Patras. He also holds a Master degree in Communication and Network Systems from University of Athens. He has a 10-year work experience as a Java and C++ developer in the Telecommunication and IT industry participating in various projects. He currently works as a senior software developer in the IT sector where he is mainly involved with projects for the EU requiring extensive java skills.","sameAs":["http:\/\/www.systemcodegeeks.com\/"],"url":"https:\/\/www.systemcodegeeks.com\/author\/nassos-hasiotis\/"}]}},"_links":{"self":[{"href":"https:\/\/www.systemcodegeeks.com\/wp-json\/wp\/v2\/posts\/890","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.systemcodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.systemcodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.systemcodegeeks.com\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/www.systemcodegeeks.com\/wp-json\/wp\/v2\/comments?post=890"}],"version-history":[{"count":0,"href":"https:\/\/www.systemcodegeeks.com\/wp-json\/wp\/v2\/posts\/890\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.systemcodegeeks.com\/wp-json\/wp\/v2\/media\/185"}],"wp:attachment":[{"href":"https:\/\/www.systemcodegeeks.com\/wp-json\/wp\/v2\/media?parent=890"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.systemcodegeeks.com\/wp-json\/wp\/v2\/categories?post=890"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.systemcodegeeks.com\/wp-json\/wp\/v2\/tags?post=890"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}