Problems with Blank Spaces

Hi to all.

How can I pass to the stat command a file path with blank spaces? And another question, if I use stat command like this:

stat / -name "*.sh" -user $user_name -exec stat -c %n%x {} \;

How can I get the result with a ":" into the name of the file and the time of the last modification?

Thanks for reading.

probably you have find instead of first stat

BTW, this is working for me for these files.

$ ls -1  
aaa:vv
space file
$ find . -type f -exec stat -c %n%x {} \;
./space file2010-05-21 13:19:40.000000000 +0200
./aaa:vv2010-05-21 13:19:27.000000000 +0200
$ 

Thanks anchal_khare, your code works.

I found the problem.

#If I do this, it doesn't works.
for i in `find / -name "*.sh" -user $user_name 2> /dev/null | tr " " "_"`
do
            script_path=`echo "$i" | tr "_" " "`
            stat $script_path
done


#I must use "" with the $script_path. Like this, it works.
for i in `find / -name "*.sh" -user $user_name 2> /dev/null | tr " " "_"`
do
            script_path=`echo "$i" | tr "_" " "`
            stat "$script_path"
done 

Two hours lost. I really hate this errors.

OK, and about the second question? Using the first post code, how can I get the result with a ":" between the name of the file and the time of the last modification?

just put a colon after the %n

find . -type f -exec stat -c %n:%x {} \;
1 Like

Thanks, it's works great.