Отсортировать все файлы по числовому имени и сохранить

вы можете использовать команду grep , на странице руководства вы найдете:

grep searches for PATTERN in each FILE. A FILE of “-” stands for standard input. If no FILE is given, recursive searches examine the working directory, and nonrecursive searches read standard input. By default, grep prints the matching lines.

-o, --only-matching Print only the matched (non-empty) parts of a matching line, with each such part on a separate output line.

-e PATTERN, --regexp=PATTERN Use PATTERN as the pattern. If this option is used multiple times or is combined with the -f (--file) option, search for all patterns given. This option can be used to protect a pattern beginning with “-”.

на ваш вопрос:

echo 'select {{112,department}},{{112,client}},{{112,place}} from table where id=1 and {{112,cgid}} and {{113,evid}}' | grep -o -e "{\{2\}[^{]*}\{2\}"
  • {\{2\}означает, что символ { встречается ровно два раза.
  • [^{]*означает любые символы в любое время, кроме { .
  • }\{2\}означает, что } символов встречается ровно два раза.

результат будет:

{{112,department}}
{{112,client}}
{{112,place}}
{{112,cgid}}
{{113,evid}}
0
23.08.2020, 23:53
1 ответ

Если вы хотите использовать псевдоним, это решит вашу проблему:

компакт-диск

vim.bashrc

#Внизу добавьте следующую строку#

псевдоним ls='ls -ls --color=auto'

#сохранить и выйти

источник.bashrc

то "ls" всегда будет отображаться в списке и сортироваться.

0
18.03.2021, 23:10

Теги

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