Sed: Difference between revisions

From DWIKI
Tony (talk | contribs)
mNo edit summary
Tag: wikieditor
Tony (talk | contribs)
Tag: wikieditor
Line 39: Line 39:
or
or
  sed -r 's/.*([0-9]+).*/\1/'
  sed -r 's/.*([0-9]+).*/\1/'
==Split words==
sed -r 's/([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+).*/\4/g'

Revision as of 11:30, 17 June 2025

Stream Editor

Links

Tutorials


FAQ

+ or *

*

matches 0 or more

+

matches 1 or more

errror messages

sed: -e expression #1, char 32: unknown command: `\'

try

's/...

instead of

'/...

Replace with newline

^V^M

match whitespace

\s

replace newline

try tr instead:

tr -d '\n' < file


Edit in-place

sed -i


match number

sed 's/.*\([0-9]\+\).*/\1/'

or

sed -r 's/.*([0-9]+).*/\1/'

Split words

sed -r 's/([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+) +([^ ]+).*/\4/g'