AWK / GAWK добавление символа после сопоставления с шаблоном

Система сборки ядра Linux предоставляет множество целей сборки, лучший способ узнать о вероятно, это делается для make help :

Configuration targets:
  config      - Update current config utilising a line-oriented program
  nconfig         - Update current config utilising a ncurses menu based program
  menuconfig      - Update current config utilising a menu based program
  xconfig     - Update current config utilising a QT based front-end
  gconfig     - Update current config utilising a GTK based front-end
  oldconfig   - Update current config utilising a provided .config as base
  localmodconfig  - Update current config disabling modules not loaded
  localyesconfig  - Update current config converting local mods to core
  silentoldconfig - Same as oldconfig, but quietly, additionally update deps
  defconfig   - New config with default from ARCH supplied defconfig
  savedefconfig   - Save current config as ./defconfig (minimal config)
  allnoconfig     - New config where all options are answered with no
  allyesconfig    - New config where all options are accepted with yes
  allmodconfig    - New config selecting modules when possible
  alldefconfig    - New config with all symbols set to default
  randconfig      - New config with random answer to all options
  listnewconfig   - List new options
  olddefconfig    - Same as silentoldconfig but sets new symbols to their default value
  kvmconfig   - Enable additional options for guest kernel support
  tinyconfig      - Configure the tiniest possible kernel

Как jimmij говорит в комментариях, интересные части находятся в целях, связанных с oldconfig .

Лично я бы порекомендовал вам использовать silentoldconfig (если ничего не изменилось в файле .config или olddefconfig , если вы обновили свой ). config с новым ядром.

2
01.03.2018, 20:34
3 ответа

En awk, cuando reasignas el valor de una variable de campo, se recalcula el valor de $0:

$ echo "A B C" | awk '{ $2 = "two"; print $0 }'
A two C

Así que en tu caso:

awk 'BEGIN{OFS=FS=","} {split($3, a, "[A-Z]{3}", seps); $3 = seps[1]"-"seps[2]; print $0}' test
3
27.01.2020, 21:49

Solución cortaawk:

awk 'BEGIN{ OFS=FS="," }{ sub(/[A-Z]{3}/, "&-", $3) }1' file
  • [A-Z]{3}-patrón de expresión regular para que coincida con 3 letras mayúsculas
  • &-representa la subcadena precisa que coincidió con el patrón de expresión regular

La salida:

"111","222","AAA-BBB","333","444","555"
5
27.01.2020, 21:49

Su descripción de la lógica deseada no es 100% clara, pero el siguiente comando Sed funciona en su entrada de ejemplo:

sed 's/[A-Z]/&-/3' test-file.txt
3
27.01.2020, 21:49

Теги

Похожие вопросы