使用 BC calc 在左边保持零

keep zero on left using BC calc

我在使用 shell 脚本时遇到问题。 我尝试移动所有早于我通过参数传递的日期的文件(作为#1传递的文件夹中的#2),我目前使用

#/bin/bash 
cd        # Parameter 1:
for i in * 
do 
var=$(echo $(ls -l --time-style=+%d%m%y $i) | awk '{print }' | bc) 
temp=$(echo  | bc) 
if [ $var -lt $temp ] 
then 
cp $i /home/igor/olders 
fi 
done

但问题是日期在第 10 天之前。我不知道如何使这个数字大于订单,例如 01/07/16 将小于 13/06/16。有人可以帮助我吗?

您可能想使用评论中建议的替代方法:

find -newerXY reference

引用manpage for find(1)

Compares the timestamp of the current file with reference. The reference argument is normally the name of a file (and one of its timestamps is used for the comparison) but it may also be a string describing an absolute time. X and Y are placeholders for other letters, and these letters select which time belonging to how reference is used for the comparison.
Some combinations are invalid; for example, it is invalid for X to be t. Some combinations are not implemented on all systems; for example B is not supported on all systems. If an invalid or unsupported combination of XY is specified, a fatal error results. Time specifications are interpreted as for the argument to the -d option of GNU date. If you try to use the birth time of a reference file, and the birth time cannot be determined, a fatal error message results. If you specify a test which refers to the birth time of files being examined, this test will fail for any files where the birth time is unknown.

如果您想坚持您的脚本,只需更改 ls 命令的格式即可。当您可能需要 --time-style=+%y%m%d(需要与脚本中的参数或开关相同的样式)时,您当前使用 --time-style=+%d%m%y