edit:
I dont know you are a bot or a man who close this, but
I DONT WANT TO FIND FILES WhICH HAVE SPACE IN THEIR NAMES. I WANT TO MOVE THEM, PLEASE STOP CLOSING THIS.
original:
I have a script that finds n
number of files into a folder. It works perfectly until there is a file with space in it's name.
mv $(find . -maxdepth 1 -mindepth 1 -type f | sort | grep -m 10 '.*') ./myFolder
As it is understandable it try to reach every part of the name as a separate file.
Then I tried to fix it with replacing spaces:
mv $(find . -maxdepth 1 -mindepth 1 -type f | sort | grep -m 10 '.*' | tr " " "\ ") ./myFolder
Ans it didn't work neither, although when I hardcode one move it works just fine:
mv Screenshot\ from\ 2020-09-05\ 01-07-36.png ./Folder04
So I want to know what is wrong here?
Why tr
command does not replace all spaces with \space?
And how can I fix this?
P.S: I read these links and they didn't help:
https://unix.stackexchange.com/questions/392393/bash-moving-files-with-spaces
mv a file that contains spaces from a shell script
moving a file with spaces in name
https://superuser.com/questions/295994/how-do-i-rename-files-with-spaces-using-the-linux-shell/295997