Экран завершения работы, занимающий слишком много времени открываться в Ubuntu 8.04

Если locate иски Вы (это быстро, но только так же хорошо как новое выполнение sudo updatedb). Можно работать locate использование его собственного встроенного regex средства...

Вот является параметр управляемым сценарием, чтобы сделать то, что Вы хотите. Назовите его с 1$ как "abcde", который Вы ищете и с последующими параметрами как каталоги:

#!/bin/bash
a=("$@"); r=''
for ((i=1;i<${#a[@]};i++)); do r="$r|${a[i]}"; done
locate --regex  "(${r:1}).*/[^/]*${a[0]}[^/]*$"

Вызов в качестве примера похож на это:

$ ./script_name 'z' "$HOME/bin/perl" "$HOME/type/stuff"

Как предложено jasonwryan, вот прокомментированная версия сценария.
Примите во внимание это locate всегда выводы полностью определяли пути.

#!/bin/bash

# Note: Do not use a trailing / for directory names
# 
# Any of the args can be an extended regex pattern. 
#
# Create an array `a` which contains "$1", "$2", "$3", etc... (ie. "$@")
# writing the $-args to an array like this (using quotes) solves 
#   any possible problem with embedded whitespace 
a=("$@")
#
# Set up an empty string which is to be built into a regex pattern 
#   of all directroy names (or an appropriate regex pattern)
r=''
#
# Each regex pattern is to be an extended regex    
# Each regex pattern is concatenated to the preceding one 
#   with the  extended-regex 'or' operator |
#
# Step through the array, starting at index 1 (ie, $2),
#   and build the 'regex-pattern' for the directories 
for ((i=1;i<${#a[@]};i++)); do r="$r|${a[i]}"; done
#
# Run 'locate' with
#                           |the target file pattern $1  | 
#                |zero-to-| |preceded and followed by    |
#                |-many   | |zero-to-many non-slash chars|
#                |anything| |               |‾‾‾‾‾‾‾‾‾‾‾‾
#                 ‾‾‾‾‾‾‾|| |               |   
locate --regex  "(${r:1}).*/[^/]*${a[0]}[^/]*$"
#        ________|      |  | 
#       |directory-regex| last
#       | in brackets ()| slash      
#       |stripped of its|
#       |leading "|"    |
#
0
06.05.2011, 16:52
1 ответ

Необходимо обновить. 8.04 достиг конца жизни на рабочем столе и только получает критические исправления безопасности для определенных пакетов, используемых на выпуске сервера.

1
28.01.2020, 02:53

Теги

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