В ударе можно использовать shopt -s nullglob
расшириться до пустого массива, при отсутствии соответствий.
В POSIX окружает без nullglob
, можно избежать этой проблемы путем проверки, что имя файла, передаваемое на самом деле, существует при наличии [ -e "$file" ] || [ -L "$file" ] || continue
как первая часть Вашего for
цикл.
Я предложил бы включить средство отладки Вашей оболочки, предположив, что Вы используете Bash.
$ set -x
Этот вывод покажет Вам, что происходит негласно, когда Вы выполняете команду, которая производит этот вывод.
Тот вывод со времени /usr/bin/time
команда, снабжаемая префиксом к каждой команде, Вы работаете. Для получения того вывода я предполагаю, что Вы используете или оболочку C (csh) или Турбо оболочку C (tcsh).
$ tcsh
$ time sleep 2
0.000u 0.000s 0:02.00 0.0% 0+0k 0+0io 0pf+0w
Причиной я подозреваю это, является a tcsh
оболочка - это, когда я выполняю команду /usr/bin/time
в оболочке Bash вывод похож на это:
$ /usr/bin/time sleep 2
0.00user 0.00system 0:02.02elapsed 0%CPU (0avgtext+0avgdata 580maxresident)k
0inputs+0outputs (0major+180minor)pagefaults 0swaps
Выводом можно управлять с помощью -f
или --format
переключатель, таким образом, вывод Вы видите, мог быть достигнут в Bash также, но должен будет быть сделан намеренно.
Если Вы выполняете команду /usr/bin/time
в подробном режиме, (-v
) Вы получите все подробности о каждом поле как это:
$ /usr/bin/time -v sleep 2
Command being timed: "sleep 2"
User time (seconds): 0.00
System time (seconds): 0.00
Percent of CPU this job got: 0%
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:02.00
Average shared text size (kbytes): 0
Average unshared data size (kbytes): 0
Average stack size (kbytes): 0
Average total size (kbytes): 0
Maximum resident set size (kbytes): 584
Average resident set size (kbytes): 0
Major (requiring I/O) page faults: 0
Minor (reclaiming a frame) page faults: 184
Voluntary context switches: 2
Involuntary context switches: 4
Swaps: 0
File system inputs: 0
File system outputs: 0
Socket messages sent: 0
Socket messages received: 0
Signals delivered: 0
Page size (bytes): 4096
Exit status: 0
Если Вы выстраиваете в линию исходный вывод:
77410.101u 124.968s 1:42:43.49 657.9% 0+0k 0+1353384io 0pf+0w
^^^^^^^^^^ ^^^^^^^^ ^^^^^^^^^^ ^^^^^^ ^^^^ ^^^^^^^^^^^ ^^^^^^
1 2 3 4 5 6 7
Можно вручную сделать тот же формат как это:
$ /usr/bin/time -f '%Uu %Ss %E %P %X+%Dk %I+%Oio %Fpf+%Ww' sleep 2
0.00u 0.00s 0:02.00 0% 0+0k 0+0io 0pf+0w
После того как Вы можете определить где вызов к /usr/bin/time
делается можно настроить вывод путем взятия пика в странице справочника для time
. Существует много опций, которые могут быть включены в этот вывод.
$ man time
выборка
Time
%E Elapsed real time (in [hours:]minutes:seconds).
%e (Not in tcsh.) Elapsed real time (in seconds).
%S Total number of CPU-seconds that the process spent in kernel mode.
%U Total number of CPU-seconds that the process spent in user mode.
%P Percentage of the CPU that this job got, computed as (%U + %S) / %E.
Memory
%M Maximum resident set size of the process during its lifetime, in Kbytes.
%t (Not in tcsh.) Average resident set size of the process, in Kbytes.
%K Average total (data+stack+text) memory use of the process, in Kbytes.
%D Average size of the process's unshared data area, in Kbytes.
%p (Not in tcsh.) Average size of the process's unshared stack space, in Kbytes.
%X Average size of the process's shared text space, in Kbytes.
%Z (Not in tcsh.) System's page size, in bytes. This is a per-system constant, but varies between systems.
%F Number of major page faults that occurred while the process was running. These are faults where the page has to be read
in from disk.
%R Number of minor, or recoverable, page faults. These are faults for pages that are not valid but which have not yet been
claimed by other virtual pages. Thus the data in the page is still valid but the system tables must be updated.
%W Number of times the process was swapped out of main memory.
%c Number of times the process was context-switched involuntarily (because the time slice expired).
%w Number of waits: times that the program was context-switched voluntarily, for instance while waiting for an I/O operation
to complete.
I/O
%I Number of file system inputs by the process.
%O Number of file system outputs by the process.
%r Number of socket messages received by the process.
%s Number of socket messages sent by the process.
%k Number of signals delivered to the process.
%C (Not in tcsh.) Name and command-line arguments of the command being timed.
%x (Not in tcsh.) Exit status of the command.
Дополнительную информацию см. в странице справочника.
Оказывается, что Ваш вопрос о выводе, показываемом автоматически, вызывается установкой этой переменной среды в csh/tcsh.
из tcsh страницы справочника
The time shell variable can be set to execute the time builtin command after the completion of any process that takes more than a given number of CPU seconds.
Установите время на 5 секунд.
$ set time=5
Подтвердите:
$ set|grep time
time 5
Проверьте его:
$ bash -c "while [ 1 ];do echo hi; done"
hi
hi
...
...waited ~5 seconds, then Ctrl-C to stop it
5.650u 1.471s 0:09.68 73.5% 0+0k 0+0io 0pf+0w
Вывод только обнаружится, если задача, которую Вы выполняете, использует больше, чем число секунд процессорного времени, установленного переменной $time
.
time
встроенное в ударе также, и его вывод отличается от/usr/bin/time
(реальный, пользователь, sys более чем три строки). – Ulrich Schwarz 14.10.2013, 08:11