I'm finding really hard to use sed command, plus I can't seem to find well written tutorials.
Let me say that I worked with regular expression in other languages (Python, JavaScript, Java), so that shouldn't be the problem.
So, here are my questions (a "theoretical" one and a more practical one):
are regular expressions used in
sedexactly the same as the ones used by Python/JS/Java? I read about BREs and EREs, but how much are they different? Shouldn't ERE be an extension of BRE?if I want to, say, just extract something from a piped output, what's the
sedsyntax to do that?
Details about the second question: say I have the output of uptime piped with sed:
uptime | sed ...
Given an example output from uptime: 18:13 up 5:12, 2 users, load averages: 0,45 0,37 0,40, I want to parse the single uptime in the form of two separated numbers (hours and minutes), and then I want to display them in the form of xxhyym (xx are the hours, yy the minutes).
And to finish, here's what I'd do in Python:
hh, mm = re.match(r'\s+ up \s+(\d{1,2}):(\d{1,2})').groups()
print '%sh%sm' % (hh, mm)