-3

I recently took backup of one of my server's drive on AWS using one of the software and now at the time of restoring it i found out it took too long to restore as its having billions of files to restore. I tried to restore it from AWS itself but my problem is backup software created two directories inside my parent directories. I'm looking out some shell script by which i can move file parent direcoties and remove the direcories created by backup software.

Current dir structure :- /opt/folder_to_restore/file_to_restore.pdf$/20211013060615/file_to_restore.pdf

Expected dir strcture :- /opt/folder_to_restore/file_to_restore.pdf

root
  • 39
  • 2
  • 8
  • Nobody is going to write that script for you. Write it, if you encounter problems feel free to post it on [so] or [unix.se]. Here it's rather off topic anyway. – Gerald Schneider Jan 18 '22 at 11:19
  • i figured out the solution for this. simple find command will work for me. Here its find . -type d -iname "*$" -exec bash -c ' loc="$1" ; file="${loc##*\/}" ; mv "$loc/"*"/${file%$}" "${loc%$file}${file%$}"' foo "{}" \; – root Jan 18 '22 at 13:14

1 Answers1

0
find . -type d -iname "*$" -exec bash -c ' loc="$1" ; file="${loc##*\/}" ; \
  mv "$loc/"*"/${file%$}" "${loc%$file}${file%$}"' foo "{}" \;

Above find command is working for me.

Gerald Schneider
  • 23,274
  • 8
  • 57
  • 89
root
  • 39
  • 2
  • 8