问题:
我正在bash
从书籍(Linux Shell Scripting with Bash,Ken O. Burch)学习,我现在关注的这本书正在使用这个命令:
/usr/bin/statftime
但我在 Linux 上找不到这个命令
我正在使用 Debian 9.0 延伸版
问题:
您能告诉我有关此命令的信息吗?是否可以在 Debian 上安装它以及如何在 Debian 上安装它?
编辑:
这本书是我读过的最好的书之一bash
(Linux Shell Scripting with Bash,Ken O. Burch)(@Gilles),所以这可能不是一个技巧,我将发布下面的代码:
这是代码:
#!/bin/bash -x
#
# polling.sh: a daemon using polling to check for new files
shopt -s -o nounset
declare -rx SCRIPT=${0##*/}
declare -rx INCOMING_FTP_DIR="/home/ftp/ftp_incoming"
declare -rx PROCESSING_DIR="/home/ftp/processing"
declare -rx statftime="/usr/local/bin/statftime"
declare FILE=""
declare FILES=""
declare NEW_FILE=""
printf "$SCRIPT started at %s\n" "`date`"
# Sanity checks
if [[ ! -d /home/ftp/ftp_incoming ]] || [[ ! -d /home/ftp/processing ]]
then
mkdir -p /home/ftp/ftp_incoming
mkdir -p /home/ftp/processing
if [ "$?" -ne 0 ]
then
echo "You are a idiot"
else
echo "You succeded!"
fi
fi
if test ! -r "$INCOMING_FTP_DIR"
then
printf "%s\n" "$SCRIPT:$LINENO: unable to read the incoming directory --aborted" >&1
exit 1
fi
if test ! -r "$PROCESSING_DIR"
then
printf "%s\n" "$SCRIPT:$LINENO: unable to read the incoming directory --aborted" >&1
exit 1
fi
if test ! -r "$statftime"
then
printf "%s\n" "$SCRIPT:$LINENO: unable to find or execute $statftime --aborted" >&1
exit 1
fi
# Poll for new FTP files
cd $INCOMING_FTP_DIR
while true
do
#check for new files more than 30 minutes unchanged
FILES=`find . -type f -mmin +30 -print`
# If new files exist, move them to the processing directory
if [ ! -z "$FILES" ]
then
printf "$SCRIPT: new files have arrived at %s\n" "`date`"
printf "%s\n" "$FILES" |
{
while read FILE
do
# Remove leading "./"
FILE=${FILE##*/}
# Rename the file with the current time
NEW_FILE=`$statftime -f "%_L%_a_%T.dat" "$FILE"`
if [ -z "$NEW_FILE" ]
then
printf "%s\n" "$SCRIPT:$LINENO: statftime failed to create a new filename--skipping"
else
# Move the file to the processing directory
printf "%s\n" "$SCRIPT: moved $FILE to $PROCESSING_DIR/$NEW_FILE"
mv "$FILE" "$PROCESSING_DIR/$NEW_FILE"
fi
done
}
fi
sleep 30
done
printf "$SCRIPT finished unexpectedly at %s\n" "`date`"
exit 1
以下是有关该命令的一些信息: