In the task of Linux find command i think there is a bug, i did it correctly and it still says an error of not all files copied.
my solution was:
find /var/www/html/blog -name ‘.css’ -exec cp --parents {} /blog
I also tried with “-type f” still error
also tried with “-not -type d” same
i also tried:
cd /var/www/html/blog
find . -name '.css’ -exec cp --parents {} /blog
and still error.
Every time I also checked it with
find /blog | wc -l
and see that it matched to the “*.css” files number in the /var/www/html/blog
Is this a bug? or an I doing something wrong?
In find command after -exec option you should add '\;'
as ending for -exec command.
So, for example (from my case for this task):
sudo find ./ -user yousuf -exec cp -p --parents {} /blog/ \;
Hope this helps you.
i did it, it still error
Is this variant still give error?
For your case:
sudo find /var/www/html/blog/ -name ‘*.css’ -exec cp -p --parents {} /blog/ \;
Make attention to final slash in path and final '\;'
Maybe -p
(preserve ownership) also necessary (I don`t remember).
still error, I think there is a bug
Can you post the task and error what you got?
Try to compare folder structure of source and destination folders.
find . -name '*.css'
in source folder
And same command after copy for destination folder. Will it be difference? Any other files except css? Right folder structure?
Hmm…
I don’t see any mistakes. And this command was correct for my task. Maybe it is the bug.
i have the same issue. i have tried everything, still nothing worked
i dont know know whether to skip the task or just leave it
Hi folks
I think it’s a bug.
I’ve tried several approaches to solve this problem:
-
I tried to use full paths
find /var/www/html/blog -type f -name '*.css' -exec cp --parents {} /blog \;
-
… and short paths
cd /var/www/html && find . -type f -name '*.css' -exec cp --parents {} /blog \;
-
… and keep the original permissions
find /var/www/html/blog -type f -name '*.css' -exec cp -a --parents {} /blog \;
I’m sure that all the requirements are met
The target directory contains only the required files.
[root@stapp02 ~]# ls /blog/
var
[root@stapp02 ~]# find /var/www/html/blog -type f -name '*.css' | wc -l
765
[root@stapp02 ~]# find /blog -type f | wc -l
765
[root@stapp02 ~]# find /blog -type f | egrep '\.css$' | wc -l
765
@tsanghan, thanks for the answer!
As I mentioned in my previous comment, I’d already tried short paths. Frankly, it was my first thought because this task is almost the same as #6 «Linux User Files» from Level 1 of Linux.
it is definitely a bug
Have the same issue:
With that command test find.py failed
[root@stapp03 ~]# find /var/www/html/ecommerce -type f -name '*.php' -exec cp --parents {} /ecommerce \;