bash - How to check files present or not in directory with mask defined in variable -


i have bash script, list files mask

offset1=`date +%y%m%d -d "2 day ago"` 

and move in directory. files format example - *160123*.log need check, if files mask $offset1 exists, move in directory $dir, else exit script.

i tried like

if [ -r *$offset1* ];then 

but nothing

how this?

offset1=$(date +%y%m%d -d "2 day ago") f in *"$offset1"*;     echo "$f" done 

you should use $() syntax instead of backticks, , use globbing list files. remember quote $f in mv statement, in case of files spaces in them.


Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

json - Gson().fromJson(jsonResult, Myobject.class) return values in 0's -