User Tools

Site Tools


sysadminery:sed

This is an old revision of the document!


escaping

check out uptime. Sample output:

   11:34:56 up 9 days,  3:24,  5 users,  load average: 3.08, 4.04, 14.66

and since i'm sure you forgot: load is “processes waiting for cpu time to execute”, the 3 numbers are “in the last minute”, “in the last 5 minutes”, and “in the last 15 minutes”. (i think).

anyway, let's get one of those numbers. Here's the sed command:

uptime | sed 's/^.*load average: \(\([0-9.]\)\{3,\}\).*$/\1/'
  • escape the parenthesis.
  • escape the brackets.
  • there is no \d.
  • don't escape the dot.
  • escape the braces.
  • Now, outside of the brackets, don't escape the dot. You'll notice that not escaping the dot now does the opposite.
  • capture group 1 is not $1, it's \1.
sysadminery/sed.1746545898.txt.gz · Last modified: 2025/05/06 15:38 by adam