Инструменты пользователя

Инструменты сайта


os:linux:utils

Различия

Показаны различия между двумя версиями страницы.

Ссылка на это сравнение

Предыдущая версия справа и слеваПредыдущая версия
Следующая версия
Предыдущая версия
os:linux:utils [16.09.2024 07:06] – [gzip] viacheslavos:linux:utils [18.03.2025 19:48] (текущий) – [read] viacheslav
Строка 311: Строка 311:
 # Отключить ошибки, в основном Permission denied # Отключить ошибки, в основном Permission denied
 find / -name 'ddd' 2> /dev/null find / -name 'ddd' 2> /dev/null
 +# Удалить файлы business-* старше 14 дней в каталогах business-*
 +find "/opt/app/business-*" -name "business-*" -type f -mtime +14 -delete
 +# Создать подкаталог old, заархивировать файлы (нерекурсивно) старше вчерашнего дня, удалить оригиналы, удалить архивы старше 30 дней
 +mkdir -p /opt/archive/jfr/old
 +find /opt/archive/jfr -maxdepth 1 -daystart -mtime +1 -type f | \
 +xargs tar czf /opt/archive/jfr/old/$(date -d '-2 day' +%F-%s).tar.gz --remove-files && \
 +find /opt/archive/jfr/old -mtime +30 -delete
 </code> </code>
 The command termination ''+'' instead of ''\;'' highly optimizes the exec clause by not running the rm command for each file present on the file system. It is more ubiquitous, being specified by POSIX. ''-delete'' is from FreeBSD from 1996, not added to GNU find until 2004, ''-exec cmd {} +'' is from SysV in 80s, standardised by POSIX in 1992, added to GNU ''find'' in 2005. [[https://unix.stackexchange.com/questions/167823/finds-exec-rm-vs-delete]] The command termination ''+'' instead of ''\;'' highly optimizes the exec clause by not running the rm command for each file present on the file system. It is more ubiquitous, being specified by POSIX. ''-delete'' is from FreeBSD from 1996, not added to GNU find until 2004, ''-exec cmd {} +'' is from SysV in 80s, standardised by POSIX in 1992, added to GNU ''find'' in 2005. [[https://unix.stackexchange.com/questions/167823/finds-exec-rm-vs-delete]]
Строка 546: Строка 553:
 echo "$server" echo "$server"
 srv-mail1 srv-mail1
 +
 +# Разделить строку на 2 части
 +$ i="v2.2.187 3826893 Very important commit, absolutely brilliant"
 +$ read -r tag description <<< $i
 +$ echo $tag
 +v2.2.187
 +$ echo $description
 +3826893 Very important commit, absolutely brilliant
 +</code>
 +[[https://stackoverflow.com/questions/10520623/how-to-split-one-string-into-multiple-variables-in-bash-shell|How to split one string into multiple variables in bash shell]]
 +===== rm =====
 +remove files or directories
 +<code bash>
 +# Удалить всё, в т. ч. файлы с точками в начале имени
 +rm -rf -- ..?* .[!.]* *
 </code> </code>
  
os/linux/utils.1726470367.txt.gz · Последнее изменение: 16.09.2024 07:06 — viacheslav

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki