Sed

From unixformat Knowledge Base Wiki
Revision as of 01:14, 26 May 2021 by Admin (talk | contribs) (sed Stream Editor commands)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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