John Bailey
John Bailey

Reputation: 11

Redirecting output for find & exec to a log file

I created a script for moving the files based on the below reference. I am trying to capture all the files activity that are picked up and moved from source to destination along with any unsuccessful files. I tried pipping the output to a log file, but after operation the log file size is 0. Any recommendations please?

Reference Doc# https://unix.stackexchange.com/questions/59112/preserve-directory-structure-when-moving-files-using-find

Below is the code block

destination=$(cd -- "$destination" && pwd)
cd -- "$source" &&
find . -type f -newermt $startdays -not -newermt $enddays -exec sh -c '
  for x do
    mkdir -p "$0/${x%/*}"
    mv "$x" "$0/$x"
  done
' "$destination" {} + >> output.log

Upvotes: 0

Views: 614

Answers (1)

William Pursell
William Pursell

Reputation: 212248

By default, mv does not produce any output. If you want it to produce output, try mv -v.

Upvotes: 1

Related Questions