Difference between revisions of "Sed"

From unixformat Knowledge Base Wiki
Jump to navigation Jump to search
(sed Stream Editor commands)
 
Line 1: Line 1:
<code>Instead of the cut command, use sed to remove the last 4 characters in a text file file1, number of characters determined by the number of ....s</code><blockquote><code>sed "s/....$//" file1</code> </blockquote><code>or to print the last 4 characters</code><blockquote><code>sed "s/.*\(....$\)/\1/" file1</code></blockquote>
Instead of the cut command, use sed to remove the last 4 characters in a text file file1, number of characters determined by the number of ....s<blockquote><code>sed "s/....$//" file1</code> </blockquote><code>or to print the last 4 characters</code><blockquote><code>sed "s/.*\(....$\)/\1/" file1</code></blockquote>

Revision as of 01:17, 26 May 2021

Instead of the cut command, use sed to remove the last 4 characters in a text file file1, number of characters determined by the number of ....s

sed "s/....$//" file1

or to print the last 4 characters

sed "s/.*\(....$\)/\1/" file1