Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

160
Vistas
La versión que clasifica la cadena RPM Kernel con números en bash devuelve un resultado incorrecto

Necesito la última versión de estas 4 versiones del kernel.

  • 4.18.0-187.el8.x86_64
  • 4.18.0-193.14.3.el8_2.x86_64
  • 4.18.0-193.el8.x86_64
  • 4.18.0-80.el8.x86_64

Inicialmente usé la ordenación numérica (que devuelve la versión 0-80 incorrectamente) antes de pasar a la ordenación de versiones para el mismo

 latest_kernel_in_use=$(ls boot/vmlinuz* | sed 's/\/boot\/vmlinuz-//' | sort -V | tail -n1 )

El comando aún devuelve 4.18.0-193.el8.x86_64 frente a la salida deseada 4.18.0-193.14.3.el8_2.x86_64.

Ayúdame con la corrección en el comando. Probé adicionalmente y realmente son los sufijos .el8.x86_64 los que complican la clasificación.

[Editar] Así que finalmente lo hice, eliminé la secuencia alfanumérica/alfabética final, siendo el identificador al menos un alfabeto involucrado si la versión del kernel RPM es 4.18.0-193.14.3.el8_2.x86_64 o algo así como 4.18.0-193.14 .3-genérico como se ve en Ubuntu

 latest_kernel_in_use=$(ls boot/vmlinuz* | sed 's/boot\/vmlinuz-//' | sed 's/[.-][[:alpha:]][[:alnum:][:punct:]]*//' | sort -V | tail -n1)

La salida con esto es 4.18.0-193.14.3

Puedo trabajar desde allí.

over 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

parece ser porque "e" > 1

Se me ocurrió este horror, pero estoy seguro de que hay una mejor manera.

 #!/bin/bash # list your kernels and remove "vmlinuz-" prefix KERNELS=$(find boot/ -iname "vmlinuz*" -exec basename {} \; | sed s/vmlinuz-//g) # declare empty arrays (this will be arrays to contain our version and suffix strings) VERSIONS_ARRAY=() SUFFIXES_ARRAY=() # we loop thought each kernel version for KERNEL in $KERNELS;do # we will split each part of the kernel version on the dot (".") IFS="." read -ra KERNEL_VERSION <<< "$(echo $KERNEL)" # we define 2 empty strings to collect the kernel parts VERSION_STRING="" SUFFIX_STRING="" # we set back field separator to space IFS=" " # we loop throug all parts of kernel version for KERNEL_PART in ${KERNEL_VERSION[@]};do #echo -n $KERNEL_PART # if we encounter el8 or el8_2 or x86_64 string we append to the SUFFIX_STRING if [[ "$KERNEL_PART" == "el8" ]] || [[ "$KERNEL_PART" == "el8_2" ]] || [[ "$KERNEL_PART" == "x86_64" ]] ;then SUFFIX_STRING="${SUFFIX_STRING}${KERNEL_PART}." # else, we append to the VERSION_STRING else VERSION_STRING="${VERSION_STRING}${KERNEL_PART}." fi done # we append the VERSION_STRING in VERSION_STRINGS VERSIONS_ARRAY+=("$VERSION_STRING") # we append the SUFFIX_STRING in SUFFIXES_ARRAYS SUFFIXES_ARRAY+=("$SUFFIX_STRING") done # we set the field separator to split on linebreaks IFS=$'\n' # we find the highest value in version array HIGHEST_VERSION=$(echo "${VERSIONS_ARRAY[*]}" | sort -V | tail -1) # we get the position of highest value in array for INDEX in ${VERSIONS_ARRAY[@]};do if [[ "$VERSIONS_ARRAY{[$INDEX]}" = "$HIGHEST_VERSION" ]]; then INDEX_OF_HIGHER_VERSION=$INDEX fi done # we get the corresponding suffix by index HIGHEST_VERSION_SUFFIX=${SUFFIXES_ARRAY[$INDEX_OF_HIGHER_VERSION]} # we remove the trailing dot in suffix len=${#HIGHEST_VERSION_SUFFIX} HIGHEST_VERSION_SUFFIX=${HIGHEST_VERSION_SUFFIX::len-1} echo "vmlinuz-${HIGHEST_VERSION}${HIGHEST_VERSION_SUFFIX}" # we set back field separator to space IFS=" "
over 4 years ago · Santiago Trujillo Denunciar

0

Así que finalmente lo hice, eliminé el alfabeto final/secuencia alfanumérica, siendo el identificador que hay al menos un alfabeto involucrado si la versión del kernel RPM es 4.18.0-193.14.3.el8_2.x86_64 o algo así como 4.18.0-193.14.3- genérico como se ve en Ubuntu

 latest_kernel_in_use=$(ls boot/vmlinuz* | sed 's/boot\/vmlinuz-//' | sed 's/[.-][[:alpha:]][[:alnum:][:punct:]]*//' | sort -V | tail -n1)

La salida con esto es 4.18.0-193.14.3

Puedo trabajar desde aquí.

over 4 years ago · Santiago Trujillo Denunciar

0

last_kernel_in_use=$(ls /boot/vmlinuz* | sed 's//boot/vmlinuz-//' | sed 's/[.-][[:alpha:]][[:alnum:][:punct:] ]*//' | ordenar -V | cola -n1)

(/arranque/vmlinux*) + s//arranque...)

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda