Prueba tú también
grep -q 'App Started' <(tail -f /var/log/app/app.log)
Basado en esta respuesta a su pregunta anterior
sed -n '/^.\{21\}$/! {p;q;}' file
Con GNUgrep
:
if line=$(grep -Exnvm1 '.{21}' < file); then
printf >&2 'Found "%s" which is not 21 characters long\n' "$line"
fi
(-n
anterior incluye el número de línea)
Используяawk
(это было бы проще):
awk 'length != 21 { printf("Line of length %d found\n", length); exit }' file
Или, как часть сценария оболочки,
if ! awk 'length != 21 { exit 1 }' file; then
echo 'Line of length != 21 found (or awk failed to execute properly)'
else
echo 'All lines are 21 characters (or the file is empty)'
fi
Использованиеsed
:
sed -nE '/^.{21}$/!{p;q;}' file
С помощью GNU sed
вы могли бы
if ! sed -nE '/.{21}$/!q 1' file; then
echo 'Line with != 21 characters found (or sed failed to run properly)'
else
echo 'All lines are 21 characters (or file is empty)'
fi