moving files with spaces in filename from one directory to another

Hello,

When I run following script

#!/bin/bash

cd ~/directory1

mv `ls -trF | grep -v / | tail -10 ` ~/directory2

works fine with filenames not having any space but runs into issues with filenames that have spaces tried with $file variable still doesnot work. Can someone help me

try putting your filename within quotes.. like "my file".

I m sorry didnt read the question properly n jumped to reply..

Try some thing lik this

find . -type f -exec mv {} ./DIR_NAME \;

Check for more option flags of find for ur needs.

in script include $file in quotes as "$file"

and while passing the path to script pass in quotes as
"/root/directory first"

this will work fine.