Linux Find Command ( KodeKloud Task)

Task Question:

Linux Find Command Task

Login to the Server 3 by using credentials in kodekloud.

Executing the command

  • We can do this task by using a single command Find
  • We are finding files in the directory /var/www/html/media. Given as first argument to find.
  • We can specify type of file using -type option. Where f is for file , d is for directory.
  • We can specify name of file using -name option.. Where we use wildcard expression to get only .js files.
  • From find command we can execute other commands by using -exec option.
  • In this task we use cp(copy) command to copy the .js extension files with their parent directory using argument “ — parents”.
  • Here, we find the .js extension files with their parent directory, but we need to pipe(input of find command ) to cp (copy) by using “{}”.
  • We close the command by providing “\;” in the end.

Finally check the /media folder to verify we have copied only .js files with their parent directories.

Thank you !!!!!!!

Suffering from Multiple Passion Disorder