What does this command mean?

Status
Not open for further replies.

u24c02

Advanced Member level 1
Joined
May 8, 2012
Messages
404
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,298
Visit site
Activity points
4,101
Hi.

What does this mean?

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

uname -r: print the kernel released
sed: string editor, 's replaced....
 

Hi,
uname prints the system information, -r prints the kernel version. The sed operation above used in pipeline is replacing whatever is present after first 3 digits like 1.2.3.4.5 --> 1.2.3

so uname -r | sed 's/\([0-9]*\. [0-9]*\. [0-9]*\).*/\1/' is same as uname -r.


sed 's /\([0-9]*\. [0-9]*\. [0-9]*\).*/\1/'
| | | | |
| | Start of Search Pattern | end of replacement pattern
| | |end of search pattern and begin pattern to be replaced if search pattern is found
| Substitution
|
sed command

\([PATTERN]\) store the pattern in \1 variable.
\. escaping '.' character.
[0-9] --character set 0 to 9
[Pattern]* -- 0 or more occurrence of Pattern
.* -- 0 or more occurrence of any character.

Hope this helps!
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…