Похоже, вы должны предоставить метод через --auto-key-locate, чтобы получить ключи:
$ gpg2 --auto-key-locate cert,pka,dane,wkd,keyserver --locate-keys torvalds@kernel.org gregkh@kernel.org
gpg: error retrieving 'gregkh@kernel.org' via DNS CERT: Not found
gpg: error retrieving 'gregkh@kernel.org' via PKA: Not found
gpg: error retrieving 'gregkh@kernel.org' via DANE: Not found
gpg: key 38DBBDC86092693E: public key "Greg Kroah-Hartman <gregkh@linuxfoundation.org>" imported
gpg: Total number processed: 1
gpg: imported: 1
gpg: automatically retrieved 'gregkh@kernel.org' via WKD
gpg: error retrieving 'torvalds@kernel.org' via DNS CERT: Not found
gpg: error retrieving 'torvalds@kernel.org' via PKA: Not found
gpg: error retrieving 'torvalds@kernel.org' via DANE: Not found
gpg: key 79BE3E4300411886: public key "Linus Torvalds <torvalds@kernel.org>" imported
gpg: Total number processed: 1
gpg: imported: 1
gpg: automatically retrieved 'torvalds@kernel.org' via WKD
pub rsa4096 2011-09-23 [SC]
647F28654894E3BD457199BE38DBBDC86092693E
uid [ unknown] Greg Kroah-Hartman <gregkh@linuxfoundation.org>
uid [ unknown] Greg Kroah-Hartman (Linux kernel stable release signing key) <greg@kroah.com>
uid [ unknown] Greg Kroah-Hartman <gregkh@kernel.org>
sub rsa4096 2011-09-23 [E]
pub rsa2048 2011-09-20 [SC]
ABAF11C65A2970B130ABE3C479BE3E4300411886
uid [ unknown] Linus Torvalds <torvalds@kernel.org>
uid [ unknown] Linus Torvalds <torvalds@linux-foundation.org>
sub rsa2048 2011-09-20 [E]
Если вы хотите получить «отрезанную часть»
yyy
yyyyy
Вы можете использовать
sed 's|.*/||'
, например.
echo "xxx/xxxx/xxxxx/yyy" | sed 's|.*/||'
echo "xxxx/x/xx/xx/xxxx/x/yyyyy" | sed 's|.*\/||'
output
yyy
yyyyy
(Примечание: для использования sed используется разделитель, отличный от /, в этом случае |, в команде s)
Если вы хотите получить начало строки:
xxx/xxxx/xxxxx
xxxx/x/xx/xx/xxxx/x
Вы можете использовать
sed 's|\(.*\)/.*|\1|'
, например. 8]
echo "xxx/xxxx/xxxxx/yyy" | sed 's|\(.*\)/.*|\1|'
echo "xxxx/x/xx/xx/xxxx/x/yyyyy" | sed 's|\(.*\)/.*|\1|'
выход
xxx/xxxx/xxxxx
xxxx/x/xx/xx/xxxx/x
Если вы хотите получить «отрезанную часть»
yyy
yyyyy
Вы можете использовать
sed 's|.*/||'
, например.
echo "xxx/xxxx/xxxxx/yyy" | sed 's|.*/||'
echo "xxxx/x/xx/xx/xxxx/x/yyyyy" | sed 's|.*\/||'
output
yyy
yyyyy
(Примечание: для использования sed используется разделитель, отличный от /, в этом случае |, в команде s)
Если вы хотите получить начало строки:
xxx/xxxx/xxxxx
xxxx/x/xx/xx/xxxx/x
Вы можете использовать
sed 's|\(.*\)/.*|\1|'
, например.
echo "xxx/xxxx/xxxxx/yyy" | sed 's|\(.*\)/.*|\1|'
echo "xxxx/x/xx/xx/xxxx/x/yyyyy" | sed 's|\(.*\)/.*|\1|'
выход
xxx/xxxx/xxxxx
xxxx/x/xx/xx/xxxx/x
Если вы хотите получить «отрезанную часть»
yyy
yyyyy
Вы можете использовать
sed 's|.*/||'
, например.
echo "xxx/xxxx/xxxxx/yyy" | sed 's|.*/||'
echo "xxxx/x/xx/xx/xxxx/x/yyyyy" | sed 's|.*\/||'
output
yyy
yyyyy
(Примечание: для использования sed используется разделитель, отличный от /, в этом случае |, в команде s)
Если вы хотите получить начало строки:
xxx/xxxx/xxxxx
xxxx/x/xx/xx/xxxx/x
Вы можете использовать
sed 's|\(.*\)/.*|\1|'
, например.
echo "xxx/xxxx/xxxxx/yyy" | sed 's|\(.*\)/.*|\1|'
echo "xxxx/x/xx/xx/xxxx/x/yyyyy" | sed 's|\(.*\)/.*|\1|'
выход
xxx/xxxx/xxxxx
xxxx/x/xx/xx/xxxx/x
Если вы отрезаете концы строк, dirname может соответствовать счету:
$ dirname xxxx/x/xx/xx/xxxx/x/yyyyy
xxxx/x/xx/xx/xxxx/x
$ _
Если вы пытаетесь изолировать последнюю часть строки, используйте .
$ str=xxxx/x/xx/xx/xxxx/x/yyyyy
$ echo /$(basename "$str")
/yyyyy
$ _
Вы можете использовать расширение параметра в bash, в этом случае
${parameter%word}, где word - /* ${parameter##word} где word - */Удалить последнюю часть
$ asdf="xxx/xxxx/xxxxx/yyy"
$ echo ${asdf%/*}
xxx/xxxx/xxxxx
Это описано в man bash:
${parameter%word}
${parameter%%word}
Remove matching suffix pattern. The word is expanded to produce
a pattern just as in pathname expansion. If the pattern matches
a trailing portion of the expanded value of parameter, then the
result of the expansion is the expanded value of parameter with
the shortest matching pattern (the ``%'' case) or the longest
matching pattern (the ``%%'' case) deleted. If parameter is @
or *, the pattern removal operation is applied to each posi‐
tional parameter in turn, and the expansion is the resultant
list. If parameter is an array variable subscripted with @ or
*, the pattern removal operation is applied to each member of
the array in turn, and the expansion is the resultant list.
Удалить последнюю часть
$ asdf="xxx/xxxx/xxxxx/yyy"
$ echo ${asdf##*/}
yyy
Вы можете добавить косую черту, подобную
$ echo /${asdf##*/}
/yyy
, чтобы получить именно то, что вы хотели в одном конкретном случае в соответствии с отредактированным вопросом. Но после этого вопрос был отредактирован несколькими людьми, и теперь нелегко узнать, что вы хотите.
Это описано в man bash:
${parameter#word}
${parameter##word}
Remove matching prefix pattern. The word is expanded to produce
a pattern just as in pathname expansion. If the pattern matches
the beginning of the value of parameter, then the result of the
expansion is the expanded value of parameter with the shortest
matching pattern (the ``#'' case) or the longest matching pat‐
tern (the ``##'' case) deleted. If parameter is @ or *, the
pattern removal operation is applied to each positional parame‐
ter in turn, and the expansion is the resultant list. If param‐
eter is an array variable subscripted with @ or *, the pattern
removal operation is applied to each member of the array in
turn, and the expansion is the resultant list.
Другой способ - использовать grep только для отображения последней косой черты на каждой строке и любого последующего за ней:
$ grep -o '/[^/]*$' example.txt
/yyy
/yyyyy
Объяснение:
-o сообщает grep для отображения только соответствующей части строки, а не всей строки.
Образец /[^/]*$ соответствует литеральной косой чертой /, за которой следует любой символ, кроме косой черты [^/], любое количество раз * до конца строки $. [!d3 ]
Просто потому, что другие опубликовали более «здравые» ответы, вот несколько глупый:
rev | cut -d/ -f1 | rev
rev меняет символы в каждой строке, например. abcd/ef/g становится g/fe/dcba. Затем cut вырезает первый сегмент. Наконец, он снова обратный.
Классическое решение с awk, которое рассматривает / как разделитель полей для ввода и вывода и устанавливает последнее поле в пустую строку (что на самом деле является «разыменованием» числа полей NF): [ ! d0]
$ echo "xxx/xxxx/xxxxx/yyy"|awk 'BEGIN{OFS=FS="/"};{$NF="";print $0}'
xxx/xxxx/xxxxx/
Короче, как заметил в комментариях fedorqui:
$ echo "xxx/xxxx/xxxxx/yyy"|awk 'BEGIN{OFS=FS="/"};NF--'
xxx/xxxx/xxxxx/
Вариация на этом должна заключаться в том, чтобы поместить путь в среду выполнения awk, которая будет накапливаться на сантехнике, но делает часть awk более подробной:
mypath="xxx/xxxx/xxxxx/yyy" awk 'BEGIN{OFS=FS="/"; sub(/\/([^\/]*)$/,"",ENVIRON["mypath"]);print(ENVIRON["mypath"]) };'
Добавление к ответу egmont, потому что вопрос был отредактирован ...
Используйте --complement, если вы хотите удалить первое поле с -f1.
echo "xxxx/x/xx/xx/xxxx/x/yyyyy"|rev|cut -d/ -f1 --complement|rev
xxxx/x/xx/xx/xxxx/x
echo "xxxx/x/xx/xx/xxxx/x/yyyyy"|rev|cut -d/ -f1|rev
yyyyy
Также , вопрос не совсем ясен о том, что должно происходить с входами, не содержащими никаких косых черт. xxxx => xxxx или xxxx => - дополнение
Другой способ - использовать grep только для отображения последней косой черты на каждой строке и любого последующего за ней:
$ grep -o '/[^/]*$' example.txt
/yyy
/yyyyy
Объяснение:
-o сообщает grep для отображения только соответствующей части строки, а не всей строки.
Образец /[^/]*$ соответствует литеральной косой чертой /, за которой следует любой символ, кроме косой черты [^/], любое количество раз * до конца строки $.
Если вы отрезаете концы строк, dirname может соответствовать счету:
$ dirname xxxx/x/xx/xx/xxxx/x/yyyyy
xxxx/x/xx/xx/xxxx/x
$ _
Если вы пытаетесь изолировать последнюю часть строки, используйте echo /$(basename "$str").
$ str=xxxx/x/xx/xx/xxxx/x/yyyyy
$ echo /$(basename "$str")
/yyyyy
$ _
Просто потому, что другие опубликовали более «здравые» ответы, вот несколько глупый:
rev | cut -d/ -f1 | rev
rev меняет символы в каждой строке, например. abcd/ef/g становится g/fe/dcba. Затем cut вырезает первый сегмент. Наконец, он снова обратный.
Добавление к ответу egmont, потому что вопрос был отредактирован ...
Используйте --complement, если вы хотите удалить первое поле с -f1.
echo "xxxx/x/xx/xx/xxxx/x/yyyyy"|rev|cut -d/ -f1 --complement|rev
xxxx/x/xx/xx/xxxx/x
echo "xxxx/x/xx/xx/xxxx/x/yyyyy"|rev|cut -d/ -f1|rev
yyyyy
Также , вопрос не совсем ясен о том, что должно происходить с входами, не содержащими никаких косых черт. xxxx => xxxx или xxxx => - дополнение
Классическое решение с awk, которое рассматривает / как разделитель полей для ввода и вывода и устанавливает последнее поле в пустую строку (что на самом деле является «разыменованием» числа полей NF): [ ! d0] $ echo "xxx/xxxx/xxxxx/yyy"|awk 'BEGIN{OFS=FS="/"};{$NF="";print $0}'
xxx/xxxx/xxxxx/
Короче, как заметил в комментариях fedorqui:
$ echo "xxx/xxxx/xxxxx/yyy"|awk 'BEGIN{OFS=FS="/"};NF--'
xxx/xxxx/xxxxx/
Вариация на этом должна заключаться в том, чтобы поместить путь в среду выполнения awk, которая будет накапливаться на сантехнике, но делает часть awk более подробной:
mypath="xxx/xxxx/xxxxx/yyy" awk 'BEGIN{OFS=FS="/"; sub(/\/([^\/]*)$/,"",ENVIRON["mypath"]);print(ENVIRON["mypath"]) };'
Вы можете использовать расширение параметра в bash, в этом случае
${parameter%word}, где word - /* ${parameter##word} где word - */Удалить последнюю часть
$ asdf="xxx/xxxx/xxxxx/yyy"
$ echo ${asdf%/*}
xxx/xxxx/xxxxx
Это описано в man bash:
${parameter%word}
${parameter%%word}
Remove matching suffix pattern. The word is expanded to produce
a pattern just as in pathname expansion. If the pattern matches
a trailing portion of the expanded value of parameter, then the
result of the expansion is the expanded value of parameter with
the shortest matching pattern (the ``%'' case) or the longest
matching pattern (the ``%%'' case) deleted. If parameter is @
or *, the pattern removal operation is applied to each posi‐
tional parameter in turn, and the expansion is the resultant
list. If parameter is an array variable subscripted with @ or
*, the pattern removal operation is applied to each member of
the array in turn, and the expansion is the resultant list.
Удалить последнюю часть
$ asdf="xxx/xxxx/xxxxx/yyy"
$ echo ${asdf##*/}
yyy
Вы можете добавить косую черту, подобную
$ echo /${asdf##*/}
/yyy
, чтобы получить именно то, что вы хотели в одном конкретном случае в соответствии с отредактированным вопросом. Но после этого вопрос был отредактирован несколькими людьми, и теперь нелегко узнать, что вы хотите.
Это описано в man bash:
${parameter#word}
${parameter##word}
Remove matching prefix pattern. The word is expanded to produce
a pattern just as in pathname expansion. If the pattern matches
the beginning of the value of parameter, then the result of the
expansion is the expanded value of parameter with the shortest
matching pattern (the ``#'' case) or the longest matching pat‐
tern (the ``##'' case) deleted. If parameter is @ or *, the
pattern removal operation is applied to each positional parame‐
ter in turn, and the expansion is the resultant list. If param‐
eter is an array variable subscripted with @ or *, the pattern
removal operation is applied to each member of the array in
turn, and the expansion is the resultant list.
Другой способ - использовать grep только для отображения последней косой черты на каждой строке и любого последующего за ней:
$ grep -o '/[^/]*$' example.txt
/yyy
/yyyyy
Объяснение:
-o сообщает grep для отображения только соответствующей части строки, а не всей строки.
Образец /[^/]*$ соответствует литеральной косой чертой /, за которой следует любой символ, кроме косой черты [^/], любое количество раз * до конца строки $.
Если вы отрезаете концы строк, dirname может соответствовать счету:
$ dirname xxxx/x/xx/xx/xxxx/x/yyyyy
xxxx/x/xx/xx/xxxx/x
$ _
Если вы пытаетесь изолировать последнюю часть строки, используйте echo /$(basename "$str").
$ str=xxxx/x/xx/xx/xxxx/x/yyyyy
$ echo /$(basename "$str")
/yyyyy
$ _
Просто потому, что другие опубликовали более «здравые» ответы, вот несколько глупый:
rev | cut -d/ -f1 | rev
rev меняет символы в каждой строке, например. abcd/ef/g становится g/fe/dcba. Затем cut вырезает первый сегмент. Наконец, он снова обратный.
Добавление к ответу egmont, потому что вопрос был отредактирован ...
Используйте --complement, если вы хотите удалить первое поле с -f1.
echo "xxxx/x/xx/xx/xxxx/x/yyyyy"|rev|cut -d/ -f1 --complement|rev
xxxx/x/xx/xx/xxxx/x
echo "xxxx/x/xx/xx/xxxx/x/yyyyy"|rev|cut -d/ -f1|rev
yyyyy
Также , вопрос не совсем ясен о том, что должно происходить с входами, не содержащими никаких косых черт. xxxx => xxxx или xxxx => - дополнение
Классическое решение с awk, которое рассматривает / как разделитель полей для ввода и вывода и устанавливает последнее поле в пустую строку (что на самом деле является «разыменованием» числа полей NF): [ ! d0] $ echo "xxx/xxxx/xxxxx/yyy"|awk 'BEGIN{OFS=FS="/"};{$NF="";print $0}'
xxx/xxxx/xxxxx/
Короче, как заметил в комментариях fedorqui:
$ echo "xxx/xxxx/xxxxx/yyy"|awk 'BEGIN{OFS=FS="/"};NF--'
xxx/xxxx/xxxxx/
Вариация на этом должна заключаться в том, чтобы поместить путь в среду выполнения awk, которая будет накапливаться на сантехнике, но делает часть awk более подробной:
mypath="xxx/xxxx/xxxxx/yyy" awk 'BEGIN{OFS=FS="/"; sub(/\/([^\/]*)$/,"",ENVIRON["mypath"]);print(ENVIRON["mypath"]) };'
Вы можете использовать расширение параметра в bash, в этом случае
${parameter%word}, где word - /* ${parameter##word} где word - */Удалить последнюю часть
$ asdf="xxx/xxxx/xxxxx/yyy"
$ echo ${asdf%/*}
xxx/xxxx/xxxxx
Это описано в man bash:
${parameter%word}
${parameter%%word}
Remove matching suffix pattern. The word is expanded to produce
a pattern just as in pathname expansion. If the pattern matches
a trailing portion of the expanded value of parameter, then the
result of the expansion is the expanded value of parameter with
the shortest matching pattern (the ``%'' case) or the longest
matching pattern (the ``%%'' case) deleted. If parameter is @
or *, the pattern removal operation is applied to each posi‐
tional parameter in turn, and the expansion is the resultant
list. If parameter is an array variable subscripted with @ or
*, the pattern removal operation is applied to each member of
the array in turn, and the expansion is the resultant list.
Удалить последнюю часть
$ asdf="xxx/xxxx/xxxxx/yyy"
$ echo ${asdf##*/}
yyy
Вы можете добавить косую черту, подобную
$ echo /${asdf##*/}
/yyy
, чтобы получить именно то, что вы хотели в одном конкретном случае в соответствии с отредактированным вопросом. Но после этого вопрос был отредактирован несколькими людьми, и теперь нелегко узнать, что вы хотите.
Это описано в man bash:
${parameter#word}
${parameter##word}
Remove matching prefix pattern. The word is expanded to produce
a pattern just as in pathname expansion. If the pattern matches
the beginning of the value of parameter, then the result of the
expansion is the expanded value of parameter with the shortest
matching pattern (the ``#'' case) or the longest matching pat‐
tern (the ``##'' case) deleted. If parameter is @ or *, the
pattern removal operation is applied to each positional parame‐
ter in turn, and the expansion is the resultant list. If param‐
eter is an array variable subscripted with @ or *, the pattern
removal operation is applied to each member of the array in
turn, and the expansion is the resultant list.