Difference between revisions of "Sed"

From unixformat Knowledge Base Wiki
Jump to navigation Jump to search
 
Line 1: Line 1:
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>
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>or to print the last 4 characters<blockquote><code>sed "s/.*\(....$\)/\1/" file1</code></blockquote>

Latest revision as of 01:18, 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