Зашифрованный раздел подкачки не отображается в / dev / mapper

Вот один лайнер для вашей цели,

sed 's/[^0-9]//g' file.txt| xargs | sed 's/ /,/g'

или

sed 's/[+|IdUserroot\-]*//g' file.txt | xargs | sed 's/ /,/g'

Выход:

8192,8194,8202,8245,8434,8754,8761,8762,8764,8771

Объяснение

man sed

s/regexp/replacement/
          Attempt  to  match  regexp  against the pattern space.  If successful, replace that
          portion matched with replacement.  The replacement may contain the special  charac‐
          ter  & to refer to that portion of the pattern space which matched, and the special
          escapes \1 through \9 to refer to the corresponding matching sub-expressions in the
          regexp.

g     Copy/append hold space to pattern space.

Регулярное выражение [Википедия]

[^ ]    Matches a single character that is not contained within the brackets.
For example, [^abc] matches any character other than "a", "b", or "c". [^0-9]
matches any single character that is not a number from "0" to "9".

Следовательно, используя sed, я заменил все пространством. Затем xargs поместите их в строку, разделенную пробелом,

$ sed 's/[^0-9]//g' file.txt| xargs
8192 8194 8202 8245 8434 8754 8761 8762 8764 8771

На последнем шаге я заменил все пробелы на ,, используя sed

1
задан 10 August 2016 в 23:25

0 ответов

Другие вопросы по тегам:

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