Не кажется ли вам, что это лучшая цель для ожидания вашего файла модуля?
nss-lookup.target
A target that should be used as synchronization point for all host/network name service lookups. Note that this is independent of UNIX user/group name lookups for which nss-user-lookup.target should be used. All services for which the availability of full host/network name resolution is essential should be ordered after this target, but not pull it in. systemd automatically adds dependencies of type After= for this target unit to all SysV init script service units with an LSB header referring to the "$named" facility.
Если у нас нет доступа к GNU-версии xargs/sed, мы должны взять на себя ответственность цитировать имена файлов, безопасные для xargs.
Использование:
./myscript your list of files goes here
#!/bin/bash
# user defined function: qXargs
# backslashes all chars special to xargs:
# SPC/TAB/NL/double quotes, single quotes, and backslash.
qXargs() {
printf '%s\n' "$1" |
sed \
-e "s:[\\'${IFS%?}\"]:\\\\&:g" \
-e '$!s:$:\\:' \
;
}
# loop over command-line arguments
# quote them to make xargs safe and
# break apart arg into head portion and
#'extension and slip in today's date
today=$(date +'%Y-%d-%m')
for arg
do
src=$(qXargs "$arg")
head=$(qXargs "${arg%.*}")
tail=$(qXargs "${arg##*.}")
printf '%s\n%s_%s.%s\n' \
"$src" \
"$head" "$today" "$tail" ;
done | xargs -n 2 -t mv -f --
Предполагается, что версии утилит GNU.
#!/bin/bash
### this is the./myscript file
d=$(date +'%Y-%d-%m')
printf '%s\0' "$@" |
sed -Ez "p;s/(.*)(\..*)/\1$d\2/" |
xargs -r0 -n2 -t mv -f --
Примечания: