将日期/时间值传递给 bash 函数中的触摸命令



我正在尝试编写一个bash函数(Mac OS X(,该函数在两个输入日期/时间之间搜索特定范围的文件。我尝试过用于评估两个输入的大多数变体$1$2失败。对时间进行硬编码工作正常(根据下面的用法行(,即搜索语法很好。感谢我在将两个输入传递给触摸命令时出错的指针。

function ffiles_search1 () {
echo "usage start 201911270000 end 201912102359 "
touch -t $(eval echo "$1")  /tmp/lower-date && touch -t $(eval echo "$2") /tmp/upper-date && find . -path "./Library" -prune -o  -type f -a -newer /tmp/lower-date -a ! -newer /tmp/upper-date -a -size +32k -a  ! -size +1024k -print0 | xargs -0 ls -ld | egrep -iv "|ppt|doc"
}

更正的代码,调用为

ffiles_search 201911270000 201912102359 

在函数上

function ffiles_search () {
echo "usage start 201911270000 end 201912102359 " 
touch -t "$1" /tmp/lower-date && 
touch -t "$2" /tmp/upper-date && 
find . -path "./Library" -prune -o -type f -a -newer /tmp/lower-date 
-a ! -newer /tmp/upper-date -a -size +32k -a -size -1024k -print0 | 
xargs -0 ls -ld |
egrep -iv -f $HOME/Scripts/egrep_exclusions/time_search.txt 
}

最新更新