我创建了以下脚本,将定义的旧文件从源目录移动到目标目录。它运行良好。
#!/bin/bash
echo "Enter Your Source Directory"
read soure
echo "Enter Your Destination Directory"
read destination
echo "Enter Days"
read days
find "$soure" -type f -mtime "-$days" -exec mv {} "$destination" \;
echo "Files which were $days Days old moved from $soure to $destination"
Run Code Online (Sandbox Code Playgroud)
这个脚本移动文件很好,它也移动源子目录的文件,但它不会在目标目录中创建子目录。我想在其中实现这个附加功能。
举例
/home/ketan : source directory
/home/ketan/hex : source subdirectory
/home/maxi : destination directory
Run Code Online (Sandbox Code Playgroud)
当我运行这个脚本时,它也会在 maxi 目录中移动十六进制的文件,但我需要在 maxi 目录中创建相同的十六进制并将其文件以相同的十六进制移动到那里。