Pregunta 1:agregar includepkgs=kernel*
a yum.conf
. Esto hará que nunca se actualice ningún paquete, excepto los paquetes de su núcleo. También evitará la instalación de paquetes que no comiencen con el kernel, así que asegúrese de haber instalado todo lo necesario antes de agregar esta línea. Alternativamente, puede agregar esta línea a archivos de repositorio individuales, y solo afectará eso repo
.
Pregunta 2:agregue exclude=postgresql*
de la misma manera que includepkg
. Esto hará que no se puedan instalar o actualizar paquetes cuyos nombres comiencen con postgresql
.
Вот пример сценария awk
.
awk '/..WAP../{print substr($0, index($0,"WAP") - 2, 7);}' input.csv
образец ввода:
junk
line 1 12WAP34 678
another line abWAPcdefg
WAP123
junk WAP
выход:
12WAP34
abWAPcd
объяснение:
/..WAP../{ # for line containt WAP with 2 chars wrap
wapPosition = index($0,"WAP") - 2; # find the position of WAP - 2 chars
output = substr($0, wapPosition, 7);# output is 7 chars length from wapPostion
print output; # print output
}
В GNU Awk вы можете использовать группу захвата в функции match
и получать доступ к ее содержимому через необязательный параметр массива:
$ echo ',x,x,x,x,x,xx,Yes,"1 WAP, other stuff, other stuff",no,x' |
awk 'match($0,/([0-9]).WAP/,a) {print a[1]}'
1
Более портативно, вы можете использовать match
+ substr
как
awk 'match($0,/[0-9].WAP/) {print substr($0,RSTART,1)}'
Предполагая, что WAP
может встречаться только один раз в строке, я думаю, что это, вероятно, то, что вам действительно нужно. Учитывая этот входной файл:
$ cat file
,x,x,x,x,x,xx,Yes,7,WAP,no,x
,x,x,x,x,x,xx,Yes,3 WAP,no,x
,x,x,x,x,x,xx,Yes,"1 WAP",no,x
С GNU awk:
$ awk 'match($0,/([0-9])[^,]WAP/,a){print a[1]}' file
3
1
С любым awk:
$ awk 'match($0,/[0-9][^,]WAP/){print substr($0,RSTART,1)}' file
3
1