Linux find command - looking for inputs

I tried this task many times. Took help from Google, KodeKloud community too but none of the solutions seem to work for me. Please help!!!

Screenshots:


Commands:
find /var/www/html/media -type f -name ‘.php’
find /var/www/html/media -type f -name '
.php’ |wc -l
ls -al /media
(1) I tried this
find /var/www/html/media -type f -name ‘.php’ -exec cp --parents {} /media ;
(2) And I tried this too
find /var/www/html/media -type f -name '
.php’ -exec cp --parents {} /media ;
find /media -type f -name ‘*.php’ | wc -l
ls -al /media

H i @kalakalyan43

Go first on the repository /var/www/html/media

cd /var/www/html/media
find . -type f -name '*.php’ -exec cp --parents {} /media \;

you can test the path by using tree

tree /media | more

The difference is that you will not take the all path from ‘/’ but the path from /var/www/html/media

Regard

That was a quick response! Thank you but looks like even this is failing.
Commands:
cd /var/www/html/ecommerce
find -type f -name ‘.js’ -exec cp --parents {} /ecommerce ;
tree /ecommerce | more
ls -al
find /var/www/html/ecommerce -type f -name '
.js’ | wc -l
find /ecommerce -type f -name ‘*.js’ | wc -l

Everything seems good but the result is failed!!! Please help!



It finally worked for me…
Thank you so much for the detailed explanation!!!

1 Like