0

I use 3 different kernels: 5.19.1-xanmod1-x64v2, 5.19.1-051901-generic, and 5.18.0-17.1-liquorix-amd64. Conky uses $kernel to display the full kernel version I'm using at the time. I want to to display the info on two lines like so:

5.19.1

xanmod1-x64v2

5.19.1-051901

generic

5.18.0-17.1

liquorix-amd64

I can get the first part by using ${exec uname -r | sed "s/ -[a-z].//"} but can't figure out a way to get the second part. Any suggestions? Thanks.

1 Answers1

0

It's considerably more complex, but the command

sed 's/\([0-9][\.0-9]*\)\([-0-9][\.0-9]*\)\?-\(.*\)/\1\2\n\3/'

outputs info for each of your kernels on two lines, as shown below.

[David@Fedora64 ~]$ echo 5.19.1-051901-generic | sed 's/\([0-9][\.0-9]*\)\([-0-9][\.0-9]*\)\?-\(.*\)/\1\2\n\3/'
5.19.1-051901
generic
[David@Fedora64 ~]$ echo 5.19.1-xanmod1-x64v2 | sed 's/\([0-9][\.0-9]*\)\([-0-9][\.0-9]*\)\?-\(.*\)/\1\2\n\3/'
5.19.1
xanmod1-x64v2
[David@Fedora64 ~]$ echo 5.18.0-17.1-liquorix-amd64 | sed 's/\([0-9][\.0-9]*\)\([-0-9][\.0-9]*\)\?-\(.*\)/\1\2\n\3/'
5.18.0-17.1
liquorix-amd64
David Yockey
  • 595
  • 3
  • 11
  • Thank you that works. I just had to modify it a bit for conky. $alignr${exec uname -r | sed 's/\([0-9][\.0-9]*\)\([-0-9][\.0-9]*\)\?-\(.*\)/\1\2\n\t\3/'} – NobodyInParticular Aug 25 '22 at 01:53