Уничтожить команду на основе вывода `grep`? [закрыто]

Si no sobrescribieron Makefile, puede usar VERSION, PATCHLEVELy SUBLEVELpara obtener una etiqueta específica en el historial git. Por ejemplo, si dice:

VERSION = 4
PATCHLEVEL = 4
SUBLEVEL = 38
EXTRAVERSION =
NAME = Blurry Fish Butt

puede obtener una etiqueta v4.4.38:

$ git show v4.4.38
tag v4.4.38
Tagger: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date:   Sat Dec 10 19:08:14 2016 +0100

This is the 4.4.38 stable release
(...)
commit c95b7f1fab0c76882764a5196119237c8ad436ee
Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date:   Sat Dec 10 19:08:05 2016 +0100

    Linux 4.4.38

diff --git a/Makefile b/Makefile
index b57ec79..6876efe 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 VERSION = 4
 PATCHLEVEL = 4
-SUBLEVEL = 37
+SUBLEVEL = 38
 EXTRAVERSION =
 NAME = Blurry Fish Butt

Sin embargo, tenga en cuenta que hubo 17 compromisos entre 4.4.38y4.4.39:

a34f0e8 (tag: v4.4.39) Linux 4.4.39
5d488de crypto: rsa - Add Makefile dependencies to fix parallel builds
1c0f4e0 hotplug: Make register and unregister notifier API symmetric
537e42d batman-adv: Check for alloc errors when preparing TT local data
f03531d m68k: Fix ndelay() macro
55e15b2 arm64: futex.h: Add missing PAN toggling
e29949e can: peak: fix bad memory access and free sequence
083021b can: raw: raw_setsockopt: limit number of can_filter that can be set
9a3baed crypto: mcryptd - Check mcryptd algorithm compatibility
c4db8a7 perf/x86: Fix full width counter, counter overflow
c6a5bf4 locking/rtmutex: Use READ_ONCE() in rt_mutex_owner()
b27d914 locking/rtmutex: Prevent dequeue vs. unlock race
e286b6c zram: restrict add/remove attributes to root only
a0bd6aa parisc: Fix TLB related boot crash on SMP machines
605f315 parisc: Remove unnecessary TLB purges from flush_dcache_page_asm and flush_icache_page_asm
db95986 parisc: Purge TLB before setting PTE
4bcea47 powerpc/eeh: Fix deadlock when PE frozen state can't be cleared
c95b7f1 (tag: v4.4.38) Linux 4.4.38
3
25.07.2018, 05:43
2 ответа

Вместо того, чтобы убивать процесс, вы можете проверить что-то вродепытается -перед -отключениемв файле конфигурации. Что я обычно делаю, чтобы ограничить попытки входа в систему по ssh.

0
27.01.2020, 21:33

Фон

Я смоделировал вашу cliутилиту так:

$ cat cli
#!/bin/bash

while IFS= read -r line; do
  if [ "$line" == "password" ]; then
    break
  else
    echo 'Credentials incorrect'
  fi
done

Использованиеgrep

Затем вы можете использовать grep -m1..., чтобы выйти после того, как будет найдено первое совпадение. -m1означает остановку после первого совпадения.

неверный пароль
$./cli | grep -m 1 "Credential"
blah
Credentials incorrect

$
хороший пароль
$./cli | grep -m 1 "Credential"
password
$

Использованиеsed

Использование аналогичного подходаsed:

неверный пароль
$./cli | sed '/Credential/ q'
blah
Credentials incorrect

$
хороший пароль
$./cli | sed '/Credential/ q'
password
$
0
27.01.2020, 21:33

Теги

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