Какова фактическая последовательность шагов во время RM -RF в очень большой папке?

С помощью настраиваемого диспетчера окон, такого как dwm, openbox или многих других, можно запустить этот фрагмент xclip -выбор буфера обмена при нажатии Super + C для копирования, а аналогичный сценарий в редакторе (vim, emacs и т.д.) может извлечь выделенный фрагмент и вставить его при точке.

-121--111353-

Экспорт пути перехода в терминал

export GOPATH=<go path from the Home dir.>
export GOPATH=$HOME/go
-121--138738-

Трудно предоставить фактический код, не видя формат данных, но вот что я бы сделал. Если вы можете опубликовать больше сведений, таких как ввод образцов и ожидаемый вывод, можно дать лучшие ответы.

  1. Сначала преобразуйте excels в csv или любой другой разделенный текстовый файл, который можно прочитать в Unix. Возможно, вам придется сделать это перед переносом файла в среду Unix.
  2. Используйте awk для извлечения номера телефона из столбца и grep для запроса файла журнала для строк, содержащих этот номер телефона.

    grep -f < (awk -F, «» {print $ n} «» filename.csv) logfilename > > outputfile

Что-то подобное должно работать. В $ n замените n номером столбца данных номера телефона.

0
07.12.2018, 14:47
1 ответ

Если вы запустите rm -Rf /, rmвыведет сообщение об ошибке и остановится, как указано в POSIX:

if an operand resolves to the root directory, rm shall write a diagnostic message to standard error and do nothing more with such operands.

В других случаях, или если вы принудительно rmобрабатываете /(, предполагая, что ваша версия может быть принудительно запущена, , например. GNU rmс опцией --no-preserve-root), rmудаляет файлы и каталоги, как только может. Он обрабатывает каталоги в глубине -первого порядка, так что он может удалять каталоги по мере их опустошения. Таким образом, за ваши пять секунд он, скорее всего, удалит файлы и каталоги.

Это указано в POSIX (см. ссылку выше):

For each file the following steps shall be taken:

  1. If the file does not exist:

    a. If the -f option is not specified, rm shall write a diagnostic message to standard error.

    b. Go on to any remaining files.

  2. If file is of type directory, the following steps shall be taken:

    a. If neither the -R option nor the -r option is specified, rm shall write a diagnostic message to standard error, do nothing more with file, and go on to any remaining files.

    b. If file is an empty directory, rm may skip to step 2d. If the -f option is not specified, and either the permissions of file do not permit writing and the standard input is a terminal or the -i option is specified, rm shall write a prompt to standard error and read a line from the standard input. If the response is not affirmative, rm shall do nothing more with the current file and go on to any remaining files.

    c. For each entry contained in file, other than dot or dot-dot, the four steps listed here (1 to 4) shall be taken with the entry as if it were a file operand. The rm utility shall not traverse directories by following symbolic links into other parts of the hierarchy, but shall remove the links themselves.

    d. If the -i option is specified, rm shall write a prompt to standard error and read a line from the standard input. If the response is not affirmative, rm shall do nothing more with the current file, and go on to any remaining files.

  3. If file is not of type directory, the -f option is not specified, and either the permissions of file do not permit writing and the standard input is a terminal or the -i option is specified, rm shall write a prompt to the standard error and read a line from the standard input. If the response is not affirmative, rm shall do nothing more with the current file and go on to any remaining files.

  4. If the current file is a directory, rm shall perform actions equivalent to the rmdir() function defined in the System Interfaces volume of POSIX.1-2017 called with a pathname of the current file used as the path argument. If the current file is not a directory, rm shall perform actions equivalent to the unlink() function defined in the System Interfaces volume of POSIX.1-2017 called with a pathname of the current file used as the path argument.

    If this fails for any reason, rm shall write a diagnostic message to standard error, do nothing more with the current file, and go on to any remaining files.

The rm utility shall be able to descend to arbitrary depths in a file hierarchy, and shall not fail due to path length limitations (unless an operand specified by the user exceeds system limitations).

4
28.01.2020, 02:18

Теги

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